In C source code, a literal is a token that denotes a fixed value, which may be an integer , a floating-point number, a character, or a string. A literal’s type is determined by its value and its notation.
The literals discussed here are different from compound literals , which were introduced in the C99 standard. Compound literals are ordinary modifiable objects, similar to variables. For a full description of compound literals and the special operator used to create them, see Chapter 5.
An integer constant can be expressed as an ordinary decimal numeral, or as a numeral in octal or hexadecimal notation. You must specify the intended notation by a prefix.
A decimal constant begins
with a nonzero digit. For example,
255 is the decimal constant for the base-10
A number that begins with a leading zero is interpreted as an
octal constant. Octal (or base
eight) notation uses only the digits from 0 to 7. For example,
047 is a valid octal constant
representing 4 × 8 + 7, and is equivalent with the decimal constant
39. The decimal constant
255 is equal to the octal constant
A hexadecimal constant
begins with the prefix
0X. The hexadecimal digits A to F
can be upper- or lowercase. For example,
0XFF represent the same hexadecimal
constant, which is equivalent to the decimal constant
Because the integer constants you define will eventually be used in expressions and declarations, their type is important. ...