C’s original standard, usually called C89 or ANSI C, defines 32 keywords. A keyword is a reserved word with a fixed meaning, so you cannot use it as the name of a variable, function, or type.
The 32 keywords
Here they are, grouped by what they do:
| Group | Keywords |
|---|---|
| Data types | char, double, float, int, long, short, signed, unsigned, void |
| Composite types | struct, union, enum |
| Type qualifiers | const, volatile |
| Storage classes | auto, extern, register, static, typedef |
| Control flow | break, case, continue, default, do, else, for, goto, if, return, switch, while |
| Operator | sizeof |
In alphabetical order, the list is: 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.
What the groups mean
Data types set the kind of value a variable holds. The const qualifier tells the compiler that a value should not be modified through that name. volatile tells the compiler that a value may change in ways the program does not control, such as through hardware. Storage classes control how a variable is stored and how long it exists. static has more than one meaning, depending on where it is used, and the file-level meaning is covered under static functions in c. Control-flow keywords steer which code runs. sizeof gives the size, in bytes, of a type or expression.
Keywords added in later versions of C
The list grew as the C standard was revised. C99 added inline, restrict, _Bool, _Complex, and _Imaginary. C11 added _Alignas, _Alignof, _Atomic, _Generic, _Noreturn, _Static_assert, and _Thread_local. Later revisions have added more again, so the total depends on which version of the standard you use. That is why inline is not among the original 32: it arrived with C99.
How C++ differs
C++ has its own, longer list of reserved words, including bool, class, namespace, new, delete, template, and this. Two C keywords behave differently in C++. restrict is not a C++ keyword, although some compilers offer __restrict. And C++17 removed register as a storage class, although the word is still reserved.
Keywords cannot be used as names
The compiler rejects a keyword when you use it as a name:
int for = 3; /* error: for is a reserved word */
Keywords are case-sensitive, so Int and Return are ordinary names that you can use for variables.