Understanding pointers in c

Introduction to pointers in c

Pointer is a variable just like other variables of c but only difference is unlike the other variable it stores the memory address of any other variables of c. This variable may be type of int, char, array, structure, function or any other pointers. For examples:

Pointer p which is storing memory address of a int type variable:

int i=50;
int *p=&i;

Pointer p which is storing memory address of an array:

int arr[20];
int (*p)[20]=&arr;

Pointer p which is storing memory address of a function:

char display(void);

Pointer p which is storing memory address of struct type variable:

struct abc{
int a;
float b;
struct abc *p=&var;


maddy said...

int (*p)[20]=&arr;

can u explain what this line does

jithu said...

when we point the structure means will pointer occupy 2 bytes or more than that a?

manu said...

it depends on memory management in system because in 16 bit system pointer points to 16 bit address and takes 2bytes, even if it is for struct or anithing else

Mean-2 said...

what is the benefit of pointer in c programming.....

ajeet pal said...

good knowledge of c pointer

Ajit Gupta said...

Its tough to get Pointers understanding.

Manish Kumar said...

i think the line *p= &i;

is incorrect its invalid conversion from int* to int

as per the compiation in Dev C++

Vannara Houth said...


it is basically create a variable p and let p has the address of arr first element at the same time p has space of 4 bytes to keep the address.

Sathish Kumar said...

invalid conversion..please check

Sweta Banerjee said...

int *p=&i
line is absolutely correct.
Checked in minGW as well as DevC++