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:

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

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

(2)
Pointer p which is storing memory address of an array:

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

(3)
Pointer p which is storing memory address of a function:

char display(void);
char(*p)(void)=&display;

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

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