Skip to content

Data Types

Basic

char

range: [-128,127] or [-27,27-1]

short

range: [-32768,32767] or [-215,215-1]

int

range: [-2147483648,2147483647] or [-231,231-1]

long int

range: [-2147483648,2147483647] or [-263,263-1]

Usually 8-byte. But in some older systems long is 4-byte.

long long int

range: [-2147483648,2147483647] or [-263,263-1]

8-byte.

Unsigned

Without Two's Complement.

array

int *p;
p = malloc(10*sizeof(int))
free(p);
// if init as a string you cannot use c++ to get its position
char *c = "abc"

const

const int BUF_SIZE = 1024
const int *p = &x; // cannot modify the value that p pointed to
int *const p = &x; // cannot modify the address that p pointed to
const int *const p = &x; // cannot modify both

function

// prototype
int *f2(const void *v1, const void *v2);
// variable declaration
// f1 is a pointer to a function that returns int
int (*f1)(const void *v1,const void *v2);