Form

int-literal
character-literal
| decimal-literal
| hexadecimal-literal
| octal-literal
character-literal
' c-character c-character * '
decimal-literal
nonzero-digit decimal-digit *
hexadecimal-literal
→ ( 0x | 0X ) hexadecimal-digit hexadecimal-digit *
octal-literal
0 octal-digit *
c-character
letter | digit | c-symbol | escape-sequence
c-symbol
" | q-symbol
q-symbol
space | ! | # | $ | % | & | ( | ) | * | + | , | - | . | / | : | : | < | = | > | @ | [ | ] | ^ | _ | ` | { | '|' | } | ~
letter
a | b | c | d | e | f | g | h | i | j | k | l | m
| n | o | p | q | r | s | t | u | v | w | x | y | z
| A | B | C | D | E | F | G | H | I | J | K | L | M
| N | O | P | Q | R | S | T | U | V | W | X | Y | Z
decimal-digit
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
hexadecimal-digit
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9
| A | B | C | D | E | F | a | b | c | d | e | f
non-zero-digit
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
octal-digit
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
escape-sequence
simple-escape-sequence
| octal-escape-sequence
| hexadecimal-escape-sequence
hexadecimal-escape-sequence
→ ( \x | \X ) hexadecimal-digit hexadecimal-digit *
octal-escape-sequence
\ octal-digit
| \ octal-digit octal-digit
| \ octal-digit octal-digit octal-digit
simple-escape-sequence
\a | \b | \f | \n | \r | \t | \v | \" | \' | \\ | \?

Contextual Constraints

int-literal
Int constants must be in the range of -2,147,483,648 to 2,147,483,647 for 32 bit compilers.
Int constants must be in the range of -32,768 to 32,767 for 16 bit compilers.
character-literal
With a 16 bit compiler, a character literal can contain only 1 or 2 characters (or escape sequences.);
With a 32 bit compiler, a character literal can contain only 1 to 4 characters (or escape sequences.);

Semantics

character-literal
The value of a character literal is the code points of the characters..

Semantics

hexadecimal-digit
  1. The values of the hexadecimal digits 0 through 9 are their usual decimal values.  The values of A through F are:
    UCLCValue
    Aa10
    Bb11
    Cc12
    Dd13
    Ee14
    Ff15
    (The digits A through F are not case sensitive.)

Example

#include <stdio.h>
#include <limits.h> 

int main () {
  int i;           
  int j;           
  int k;       
  int m;       
  
  i = 1;          /* Decimal     */
  j = 020;        /* Octal       */
  k = 0X30;       /* Hexadecimal */
  m = 'A';        /* Character   */
  
  printf ("i (decimal %d) is %d\n", i, i);
  printf ("j (octal %o) is %d\n", j, j);
  printf ("k (hexadecimal %x) is %d\n", k, k);
  printf ("m (character %c) is %d\n", m, m);
  printf ("The size of the int type is %d bytes\n", sizeof(int));
  printf ("The size of the literal 1 is %d bytes\n", sizeof i);
  printf ("The size of the literal 020 is %d bytes\n", sizeof 020);
  printf ("The size of the literal 0X30 is %d bytes\n", sizeof 0X30);
  printf ("The size of the literal \'A\' is %d bytes\n", sizeof 'A');
  printf ("The range of the int type is from %d to %d\n",
          INT_MIN, INT_MAX);
  return 0;
}

Output


    

Reference Links

Math Now Radix Notation

Reference Links

Integer Literals integer-literal
Real Literals real-literal
String Literals string-literal
Character Literals character-literal
int Type int-type

External Links

MSDN C Integer Constants Visual Studio 6