News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Pointer to Pointer

Started by thiruvasagamani, Sep 22, 2008, 11:26 AM

Previous topic - Next topic

thiruvasagamani

Pointer to Pointer:

int a = 25;
int *b = &a; // having address 'a' 1000
int **c = &b; // having address 'b' 2000 and 'c' is having address 3000

From the above, address of variable 'a' is stored in 'b' , 'b' is pointer to 'a', address of pointer 'b' is stored in 'c', 'c' is a pointer to pointer 'b'. 'c' is address of address 2000. 'a' is variable, 'b' is pointer, 'c' is pointer to pointer. 'a' contains value, 'b' contains address, 'c' contains address of address. 'a' is integer, 'b' is int *, ' c' is int **. We can access value 25 by 'a', *b or **c. We can access address 1000 by &a, b, or *c. We can access address of address 2000 by &b or 'c' ( && a is invalid)
int ***d = &c;

Address of double pointer 'c' is stored in 'd', 'd' is triple pointer ***d is 25 as number of * 's increase , complexity of the program increases , program execution will slow down. It becomes difficult to understand the program.
Thiruvasakamani Karnan