C POINTER | Pointer To Pointer - with Example


A pointer is a variable that store memory address or that contains address of another variable where addresses are the location number always contains whole number. So, pointer contain always the whole number. It is called pointer because it points to a particular location in memory by storing address of that location.


        Data type *pointer name; 

Here * before pointer indicate the compiler that variable declared as a pointer. 


        int *p1; //pointer to integer type 

        float *p2; //pointer to float type 

        char *p3; //pointer to character type 

When pointer declared, it contains garbage value i.e. it may point any value in the memory.

Two operators are used in the pointer i.e. address operator(&) and indirection operator or dereference operator (*). 

Indirection operator gives the values stored at a particular address. 

Address operator cannot be used in any constant or any expression. 


void main() 


            int i=105; 

            int *p; 


            printf(“value of i=%d”,*p); 

            printf(“value of i=%d”,*/&i); 

            printf(“address of i=%d”,&i); 

            printf(“address of i=%d”,p); 

            printf(“address of p=%u”,&p); 


Pointer Expression 

Pointer assignment 

int i=10; 

int *p=&i;//value assigning to the pointer

Here declaration tells the compiler that P will be used to store the address of integer value or in other word P is a pointer to an integer and *p reads the value at the address contain in p


printf(“value of p=%d”); 

We can assign value of 1 pointer variable to other when their base type and data type is same or both the pointer points to the same variable as in the array. 

Int *p1,*p2; 



We can assign constant 0 to a pointer of any type for that symbolic constant ‘NULL’ is used such as 


It means pointer doesn’t point to any valid memory location.

Pointer to pointer 

Addition of pointer variable stored in some other variable is called pointer to pointer variable. 


Pointer within another pointer is called pointer to pointer. 


        Data type **p; 

        int x=22; 

        int *p=&x; 

        int **p1=&p; 

        printf(“value of x=%d”,x); 

        printf(“value of x=%d”,*p); 

        printf(“value of x=%d”,*&x); 

        printf(“value of x=%d”,**p1); 

        printf(“value of p=%u”,&p); 

        printf(“address of p=%u”,p1); 

        printf(“address of x=%u”,p); 

        printf(“address of p1=%u”,&p1); 

        printf(“value of p=%u”,p); 

        printf(“value of p=%u”,&x);


"pointer to pointer example in c"

"pointer to pointer c"

"dangling pointer in c"

"pointer to function in c"

"double pointer in c"

"pointer to pointer array"

"pointer arithmetic in c"

"pointer to array in c"

"pointer to pointer example in c"

"dangling pointer in c"

"pointer to function in c"

"double pointer in c"

"pointer to pointer array"