The 32 keywords at a glance
The original C standard, published in 1989 and often 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, a function or any other identifier. Here is the full list, grouped by purpose:
| Group | Keywords |
|---|---|
| Types | char, double, float, int, long, short, signed, unsigned, void |
| Storage and qualifiers | auto, const, extern, register, static, typedef, volatile |
| Control flow | break, case, continue, default, do, else, for, goto, if, return, switch, while |
| Other | enum, sizeof, struct, union |
That is 9 + 7 + 12 + 4 = 32 keywords. The sections below say briefly what each group is for.
Types
int,char,shortandlongare integer types. The standard sets minimum ranges for them, not exact sizes.signedandunsignedcontrol whether an integer type can hold negative values.floatanddoubleare floating-point types.voidmeans no type or no value. It is used for functions that return nothing, and for generic pointers.
Storage and qualifiers
automarks a local variable with automatic storage. Most programmers never write it, because local variables already have that storage by default.statickeeps a variable alive for the whole run of the program, or limits a name to the file where it is declared.externdeclares a name that is defined somewhere else.registeris a hint to the compiler, which can ignore it.constmeans the value cannot be changed through this name.volatiletells the compiler that a value can change outside the program’s control, so reads should not be optimized away.typedefgives a new name to an existing type.
Control flow
if,else,switch,caseanddefaultchoose which code runs. The switch case statement in C is the usual tool for several fixed options.for,whileanddorepeat code in loops.breakleaves the nearest loop or switch that contains it. Inside a switch, it ends the current case, which is the break statement in C that keeps each case separate.continueskips to the next iteration of a loop.gotojumps to a labeled statement. It is rarely needed in modern code, so use it with care. Learning how to use goto in C also means learning its limits.returnends a function and sends back a value, if the function has a return type.
Other keywords
enumdefines a set of named integer constants.sizeofis an operator that gives the size of a type or value in bytes. It is a keyword, but it works like an operator, not a function.structgroups several values under one type.uniongroups values that share the same memory, so only one member holds a meaningful value at a time.
Keywords cannot be used as names
Because keywords are reserved, a declaration such as int return = 5; does not compile. Words that look like ordinary names can also be keywords, so check the list before you pick a name for a variable or function.
Some names are legal in C but reserved in C++. For example, this is valid C because class is not a C keyword:
int class = 3; /* valid in C, not in C++ */
C++ has a longer keyword list that includes class, new, delete, template, namespace and bool. Code that compiles as C may therefore fail when you compile it as C++.
Keywords added after the original standard
Later C standards added more reserved words. C99 added words such as inline, restrict and _Bool. C11 added words such as _Generic and _Static_assert. In C99 through C17, the bool, true and false names come from the <stdbool.h> header as macros, not keywords. C23 made bool, true and false keywords, so newer code may not need that header.
So the count of 32 applies to the original standard. If you compile with a newer C standard, the reserved list is longer, and you should check the standard your compiler is set to use.
Summary
The original C standard has 32 keywords. They cover types, storage and qualifiers, control flow and a few other words, and none of them can be used as a name. Later standards add more, and C++ reserves a longer list still.