int, long, short

Specifier Description
short, short int Allocates 2 bytes of data storage.
int Allocates 4 bytes of data storage.
long, long int Allocates 4 bytes of data storage in 32-bit compiler mode, and 8 bytes in 64-bit compiler mode.
long long, long long int Allocates 8 bytes of data storage. The C compiler supports long long, but this is not a standard C data type. Though needed for some system programming, it may not be portable to other systems.
Notes: The amount of storage allocated for an int, short, or long integer variable is implementation-dependent.

To declare a data object having an integer data type, use an int type specifier.

The int specifier has the form:

The declarator for a simple integer definition or declaration is an identifier. You can initialize a simple integer definition with an integer constant or with an expression that evaluates to a value that can be assigned to an integer. The storage class of a variable determines how you can initialize the variable.

The unsigned prefix indicates that the object is a nonnegative integer. Each unsigned type provides the same size storage as its signed equivalent. For example, int reserves the same storage as unsigned int. Because a signed type reserves a sign bit, an unsigned type can hold a larger positive integer than the equivalent signed type.

The following example defines the short int variable flag:

short int flag;

The following example defines the int variable result:

int result;

The following example defines the unsigned long int variable ss_number as having the initial value 438888834:

unsigned long ss_number = 438888834ul;

The following example defines the identifier sum as an object of type int. The initial value of sum is the result of the expression a + b:

extern int a, b;
auto sum  = a + b;


Lexical Elements of C - Integer Constants