Character set and keywords in C

In this blog post, you will learn about the C keywords their character sets. Like other languages, C has some character sets and keywords (reserved words). It is good to know some important character sets and keywords in C because it will help during the programming.

C language character set:

  • Lowercase and uppercase letters of ISO Basic Latin Alphabet: a–z A–Z
  • Decimal digits: 0–9
  • 29 graphic characters!  ”  #  %  &  ‘ (  )  *  +  ,  – .  /  :
    ;  <  =  >  ?  [  \  ]  ^  _  {  |  }  ~
  • Whitespace characters: space, horizontal tab, vertical tab, form feed, newline (Newline indicates the end of a text line), carriage return, backspace,..etc.

 

Keywords in C (Reserved words):

Keywords are words that have special meaning to the C compiler. They are predefined (You can’t redefine it), reserved words used in programming. C89 has 32 reserved words. These keywords are case sensitive and only use for the purpose of which they are predefined.

C Reserved words

 

Note: We can not use keywords as an identifier in the programs. Let’s understand with an example C program.

#include <stdio.h>


int main()
{
    int while; //variable

return 0;
}

Output: Compiler error.

Explanation: Getting compiler error because using while keyword as an identifier.

 

Except for these old keywords, C99, C11, and C23 have some extra keywords.  Below I have mentioned some new keywords which were introduced in C99, C11, and C23.

C99

C11

C23

  • _Decimal128
  • _Decimal64
  • _Decimal32

 

Update list of keywords, you should know:

It is the newly updated list of reserved keywords in C.

auto
break
case
char
const
continue
default
do-while
double
else
enum
extern
float
for
goto
if
inline (since C99)
int
long
register
restrict (since C99)
return
short
signed
sizeof
static
struct
switch
typedef
union
unsigned
void
volatile
while
_Alignas (since C11)
_Alignof (since C11)
_Atomic (since C11)
_Bool (since C99)
_Complex (since C99)
_Decimal128 (since C23)
_Decimal32 (since C23)
_Decimal64 (since C23)
_Generic (since C11)
_Imaginary (since C99)
_Noreturn (since C11)
_Static_assert (since C11)
_Thread_local (since C11)

 

Recommended Post