Reserved Keywords

The latest specification for the C programming language is the ISO/IEC 9899:2018 standard, commonly referred to as C18. Below is a list of keywords defined in this standard. These keywords are reserved by the language for specific uses and cannot be used for other purposes, like naming variables or functions.

The table is organized into four columns for easier reference:

KeywordKeywordKeywordKeyword
autobreakcasechar
constcontinuedefaultdo
doubleelseenumextern
floatforgotoif
inlineintlongregister
restrictreturnshortsigned
sizeofstaticstructswitch
typedefunionunsignedvoid
volatilewhile_Alignas_Alignof
_Atomic_Bool_Complex_Generic
_Imaginary_NoreturnStaticassertThreadlocal

What Does "Reserved" Mean?

In the context of a programming language, "reserved" means that these keywords have a specific meaning and function within the language's syntax and cannot be used for anything other than their intended purpose. For instance, you cannot name a variable "if" or "while" because these words are reserved for control flow statements in C.

Here's a simple example demonstrating the use of some of these keywords:

#include <stdio.h>

int main() {
    int count;
    for (count = 0; count < 5; count++) {
        printf("Count is: %d\n", count);
    }
    return 0;
}

In this snippet:

  • int is a keyword used to declare an integer variable.

  • for is a keyword used to create a loop.

  • return is a keyword used to return a value from a function.

Using these reserved keywords for other purposes, like naming variables, would result in a syntax error. For instance, int for; would not be valid because for is a reserved keyword.