C Programming Keywords: The C17 List with Examples

C programming keywords have predefined roles in the language. In int score = 10;, int is the keyword and score is the name chosen by the programmer. You cannot use a keyword as an ordinary variable or function name.
This guide is based on the C17 set of keywords. When comparing lists, specify the language version: a list of 32 keywords is for the older C90 version, not all later versions of C.
The 44 C17 keywords
The following groups include each keyword once:
| Purpose | Keywords |
|---|---|
| Basic types and type modifiers | char, double, float, int, long, short, signed, unsigned, void |
| Additional types | _Bool, _Complex, _Imaginary |
| Decisions and loops | if, else, switch, case, default, for, while, do |
| Control transfers | break, continue, goto, return |
| Storage and related declarations | auto, extern, register, static, _Thread_local |
| Type qualifiers and atomic declarations | const, restrict, volatile, _Atomic |
| User-defined types and aliases | struct, union, enum, typedef |
| Function specifiers | inline, _Noreturn |
| Size, alignment, selection, and assertions | sizeof, _Alignof, _Alignas, _Generic, _Static_assert |
These tokens are listed in the C11 committee draft in section 6.4.1, and are the same in C17. See the WG14 C draft. Reservations of a keyword do not mean that all optional features of that keyword are supported by every implementation.
Read keywords in a working program
#include <stdio.h>
int main(void)
{
const int limit = 5;
int total = 0;
for (int number = 1; number <= limit; ++number) {
if (number % 2 == 0) {
continue;
}
total += number;
}
printf("Sum of odd numbers: %d\n", total);
return 0;
}
Output:
Sum of odd numbers: 9
Here, int declares an integer type, and void says that main has no parameters. The const qualifier prevents assigning to limit through this declaration. The for loop repeats the block, while if decides whether to execute continue, which advances to the next iteration. Finally, return ends the function.
It is not necessary to remember all the 44 words before writing useful programs. Begin by identifying the key words in simple instances and master a new set as needed.
Keywords are case-sensitive
The word int is a keyword, Int is not. But it is bad practice to name a variable after a type or control-flow word by changing its capitalization. Use descriptive names like item_count and total_score.
Don't assume that all names other than keywords are available. C has reserved other identifiers for library and implementation. Ordinary descriptive names (no leading underscores) are good practice for beginner code.
Common names that are not keywords
| Name | What it is in C17 |
|---|---|
main |
The conventional hosted-program entry-point function name |
printf |
A standard library function declared in <stdio.h> |
NULL |
A macro defined by several standard headers |
size_t |
A typedef name supplied by standard headers |
include |
Part of the #include preprocessing directive |
bool |
A macro from <stdbool.h> in C17 |
These distinctions help when reading compiler errors. A missing declaration for printf is normally fixed by including its header; it does not mean a keyword has been forgotten.
What changes in C23?
C23 introduces a new set of keywords and assigns some familiar spellings direct roles in the language, such as bool. Never combine a C23 list with a C17 lesson without marking the distinction. Before using newer syntax, verify the version of your compiler and the language mode you are using. How to request a standard explicitly is documented in the GCC C dialect options document.
Are sizeof and typedef functions?
No. sizeof is an operator expressed with a keyword, and typedef is a keyword used in declarations to create type aliases. Neither is a normal library function call.
Is const a guarantee that my entire program is safe?
No. It prevents modification by specific access paths or declarations. It does not check array bounds, keep allocated memory alive, or prevent unrelated pointer mistakes.
Test the example in the online C compiler, modify the loop limit to 7, and then guess the outcome of the test before running it again. The total should be 16.