w3resource logo

C Programming

C Basic, commments

Secondary Nav

Character Set

The characters that can be used to from words, numbers and expressions depend upon the computer on which the program is run. However, a subset of characters is available that can be used on most personal, micro mini and mainframe computers to form a standard program. The characters in C are grouped into the following categories :

  • Letters
  • Digits
  • Special characters
  • White spaces

A complete table of character set


A to Z in uppercase or capital letters.

a to z in lowercase or small letters.

Digits :

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Special Characters :

Character Description Character Description
, comma & ampersand
. period ^ caret
; semicolon * asterisk
: colon - minus sign
? question mark + plus sign
' apostrophe < opening angular bracket or less than sign
" quotation mark > closing angular bracket or greater than sign
! exclamation mark ( left parenthesis
| vertical bar ) right parenthesis
/ slash [ left square bracket
\ backslash ] right square bracket
~ tiled { left brace
_ under score } right brace
$ doller sign % per cent sign
# number sign    

White Spaces :

Space, line-feed, tab, form-feed, carriage-return, vertical-tab, and new-line characters are called "white-space characters" which are not visible on the screen.
White-space characters enhance readability of the program files and do same job as spaces between words and lines in the source code. C compiler ignores white-space characters at the time of reading the source code unless you use the white-space characters in string literals.

Trigraph Characters

The source character set of C source programs is contained within seven-bit ASCII character set, but is a superset of the ISO 646-1983 Invariant Code Set.
Trigraphs are a sequence of three characters starting with two consecutive question marks(??) followed by another character and allow the compiler to replace with their corresponding punctuation characters. Trigraph sequences are used in C program files in some keyboards which do not support some characters mentioned above table (Special Characters). The following table shows the list of trigraph sequences followed by an example.

Trigraph sequence Punctuation character Description
??= # comma
??( [ period
??) ] semicolon
??< { colon
??> } question mark
??! | apostrophe
??/ \ quotation mark
??' ^ exclamation mark
??- ~ vertical bar

For example, if you attempt to print the string ??<character??> with this printf statement

#include <stdio.h> main()
printf( "??< Character ??>" );

the string printed is { Character } because ??< and ??> is trigraph sequences that are replaced with the "{" and "}" character.


Comments are a good way to write notations to explain what a program does. Comments can appear anywhere in a program. C compiler ignores comments at the time of reading the source code C language supports the following two different ways of commenting.

Starts with a "/*" and ends with "*/" at the end of the comment. Comments in C language can occupy more than one line but cannot be nested. Comments can appear anywhere in a C program. This following example is a comment accepted by the compiler:

/* Comments in C language can
occupy more than one lines */
printf( "Welcome to C programming" );

Comments can appear in the same line after the statement:

printf( "Welcome to C programming" ); /* Comments can come in same line after the statement */

Comments in C language cannot contain nested comments. The example bellow causes an error:

/* This is the outer comments
/*Start to write statements*/
printf( "Welcome to C programming" ); */

Some compilers also support single-line comment preceded by two forward slashes (//). Here is an example.

// This is a single line comment.
printf( "Welcome to C programming" );

Join our Question Answer community to learn and share your programming knowledge.

Help the community:

PHP: Loop

JavaScript: Delete duplicates in an array

Oracle: Round the number