The short answer
The original C standard, C89 (also called C90), reserves 32 keywords. A keyword is a word with a fixed meaning in the language. You can’t use one as the name of a variable, function, or type. Later versions of C added more, which the last section covers.
The full list
The 32 keywords, grouped by what they’re used for:
- Data types:
char,double,float,int,long,short,signed,unsigned,void - Type qualifiers:
constandvolatile.constmarks a value as read-only.volatiletells the compiler a value may change outside the program’s control, such as a hardware register. - Storage classes:
auto,extern,register,static,typedef.statickeeps a local variable’s value between calls and limits a name to its file.externdeclares a name defined elsewhere.typedefgives an existing type a new name.registeris only a hint to the compiler, andautois the default for local variables, so you rarely write it. - Control flow:
break,case,continue,default,do,else,for,goto,if,return,switch,while - Structured types:
enum,struct,union - Operator:
sizeof, which gives the size of a type or object in bytes
Count the groups and you get 9 + 2 + 5 + 12 + 3 + 1, which is 32.
Keywords added in later C standards
C99 added five keywords: inline, restrict, _Bool, _Complex and _Imaginary. That brings the total to 37. C11 added seven more: _Alignas, _Alignof, _Atomic, _Generic, _Noreturn, _Static_assert and _Thread_local, for a total of 44. Newer standards may add more again, so check the standard for the version you’re targeting.
Keywords can’t be used as names
A keyword has a fixed meaning, so the compiler rejects it as an identifier:
int return = 5; // Error: return is a keyword
int class = 5; // Valid in C, but class is a keyword in C++
The second line is a useful trap. The word class is an ordinary name in C, so code that uses it compiles there, but the same code fails as C++.
C++ reserves more words
C++ has a longer list that includes class, template, namespace, bool and new. If you’re moving from C to C++, check the C++ list too. For the C++ side of this question, see what are C++ keywords?
Where const fits
const is one of the two type qualifiers in the list. It’s the one you’ll use most often in everyday code, and the rules for it are covered in the c const keyword guide.
Check it yourself
Try compiling a small C file that uses a keyword as a name, such as int switch = 1;. The compiler rejects it because switch is a reserved word. Trying a few of these yourself is a quick way to remember the list.