Home : C Language : Constants
Integer constants do not contain a decimal point. They are of the
smallest type that would hold them unless they have a U
or L
suffix letter:
nnn signed short int
if between -32768 and 32767 nnn U
unsigned short int
if between 0 and 32767 nnn unsigned short int
if between 32768 and 65535 nnn signed long int
if greater than -32768 or 65535 nnn L
signed long int
Octal constants have an "0
" prefix: 0
nnn
Hexadecimal constants have an "0x
" prefix: 0x
nn
Floating point constants contain a decimal point, have an
exponent, or have an F
suffix letter. They are of type double
unless they have an F
or L
suffix letter:
nn F
float
nn .
nn[E
nn]F
float
nn .
nn[E
nn]double
nn .
nn[E
nn]L
long double
Character constants are enclosed in single quotes: '
c'
. The compiler will substitute the appropriate character if any of the
following "backslash" or "escape" codes are used:
\a
Alert (bell) \b
Backspace \f
Form feed \n
Newline \r
Carriage return \t
Horizontal tab \v
Vertical tab \'
Single quote \"
Double quote \\
Backslash \0
Null \
nnnASCII code in octal (a maximum of three digits are recognised) \x
nnASCII code in hexadecimal
String constants are enclosed in double quotes: "
string"
. The compiler automatically appends a null character to the end of the
string.