C Keywords
C Keywords
A list of all C keywords can be found in the table below.
| Keyword | Description |
|---|---|
| auto | Declares a local variable that is created when its block starts and removed when it ends. This is the default for local variables, so the keyword is rarely used |
| break | Breaks out of a loop or a switch block |
| case | Marks a block of code in switch statements |
| char | A data type that can store a single character |
| const | Defines a variable or parameter as a constant (unchangeable) |
| continue | Continues to the next iteration of a loop |
| default | Specifies the default block of code in a switch statement |
| do | Used together with while to create a do/while loop |
| double | A data type that is usually 64 bits long which can store fractional numbers |
| else | Used in conditional statements |
| enum | Declares an enumerated type |
| extern | Declares a variable or function that is defined in another file |
| float | A data type that is usually 32 bits long which can store fractional numbers |
| for | Creates a for loop |
| goto | Jumps to a line of code specified by a label |
| if | Makes a conditional statement |
| inline | Suggests to the compiler that the code of a function should be inserted where the function is called |
| int | A data type that is usually 32 bits long which can store whole numbers |
| long | Ensures that an integer is at least 32 bits long (use long long to ensure 64 bits) |
| register | Suggests that a variable should be stored in a CPU register for faster access. You cannot get the memory address of a register variable |
| restrict | Tells the compiler that a pointer is the only way to access the data it points to |
| return | Used to return a value from a function |
| short | Reduces the size of an integer to 16 bits |
| signed | Specifies that an int or char can represent both positive and negative values (for int this is the default so the keyword is not usually necessary) |
| sizeof | An operator that returns the amount of memory occupied by a variable or data type |
| static | Specifies that a variable in a function keeps its value after the function ends |
| struct | Defines a structure |
| switch | Selects one of many code blocks to be executed |
| typedef | Defines a custom data type |
| union | Defines a union, a type where all members share the same memory |
| unsigned | Specifies that an int or char should only represent positive values which allows for storing numbers up to twice as large |
| void | Indicates a function that does not return a value or specifies a pointer to a data with an unspecified type |
| volatile | Tells the compiler that a variable can change at any time, for example by hardware, so it must always read the value from memory |
| while | Creates a while loop |
| _Alignas | Specifies the alignment (the memory address boundary) of a variable |
| _Alignof | Returns the alignment of a type, in bytes |
| _Atomic | Makes a variable atomic, so many threads can use it safely at the same time |
| _Bool | A data type that can only store 1 (true) or 0 (false). Include <stdbool.h> to write it as bool |
| _Complex | Declares a complex number type (a number with a real and an imaginary part) |
| _Generic | Selects an expression based on the type of a value |
| _Imaginary | Declares an imaginary number type (not supported by most compilers) |
| _Noreturn | Specifies that a function never returns, for example because it ends the program |
| _Static_assert | Checks a condition when the program is compiled, and stops with an error message if it is false |
| _Thread_local | Specifies that each thread has its own copy of a variable |
Note: The table lists the keywords in C11. C23 added a few more, like bool, true, false and nullptr.