Pointer to Pointer
Pointers can point to other pointers; there is no limit whatsoever on how many ‘pointer to pointer’ links you can have in your program. It is entirely up to you and your programming skills to decide how far you can go before you get confused with the links. Here we will only look at simple pointer to pointer link. Pointing to pointer can be done exactly in the same way as normal pointer. Diagram below can help you understand pointer to pointer relationship.
- Code for diagram :
- Features of Pointer :
- Pointer variable should have prefix '*'.
- Combination of data types is not allowed.
- Pointers are more effective and useful in handling arrays.
- It can also be used to return multiple values from a function using function arguments.
- It supports dynamic memory management.
- It reduces complexity and length of a program.
- It helps to improve execution speed that results in reducing program execution time.
ptrA gives 100, *ptrA gives 101 , ptrb is 101 ,*ptrb gives b, **ptrA gives b
comment: **ptrA means ‘value stored at memory location of value stored in memory location stored at PtrA’