วันอาทิตย์ที่ 13 มกราคม พ.ศ. 2556

คำสงวนในภาษาซี

คำสงวน (Reserved Word) เป็นคำเฉพาะที่ได้กำหนดขึ้นมา เพื่อใช้ในตัวภาษาโดยเฉพาะ ซึ่งผู้เขียนโปรแกรมไม่สามารถนำมาใช้เป็นชื่อ (Indentifiers) ได้ เช่น ไม่สามาถนำไปใช้เป็นตัวแปร (Variables) หรือ ชื่อโปรแกรมได้ คำสงวนในภาษาซี ตามมาตรฐานสถาบันมาตรฐานแห่งชาติสหรัฐอเมริกา (American National Standards Institute) มี 32 คำ
คำสงวนสำหรับภาษาซีมาตรฐาน (Standard C) มีทั้งหมด 32 คำ ดังนี้
auto
break
case
char
const
continue
default
do
double
else
enum
extern
float
for
goto
if
int
long
register
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while

และอีก 32 คำที่เพิ่มมาสำหรับ C++ ได้แก่
asm
bool
catch
class
const_cast
delete
dynamic_cast
explicit
false
friend
inline
mutable
namespace
new
operator
private
protected
public
reinterpret_cast
static_cast
template
this
throw
true
try
typeid
typename
using
virtual
wchar_t

ไม่มีความคิดเห็น:

แสดงความคิดเห็น