Sunday, February 8, 2009

Reserved Keywords and Identifiers in C

You may write identifiers or names for your variables or functions through valid characters like numbers, letters and underscores. But these identifiers should not be similar to the reserved keywords of C as they have special purpose inside your C program.

The following are the keywords:

auto break case char continue default
do double else enum exterm float
for goto if int long register
return short sizeof static struct switch
typedef union unsigned void while

An identifier must start with an underscore or a letter and may be followed by letters/underscores/numbers. I advice that identifiers should connote their function so it would be easier to distinguish them from the rest.

Sample valid identifiers are: address, name, age, mygrade, _average, total1