Added 'Pointer to pointer' section (#32819)

* Added 'Pointer to pointer' section

The 'Pointer to pointer' section describe what is pointer to pointer with an example.

* Update index.md

Changed Output header to ####
pull/34129/head^2
Papun Charan 2019-03-20 09:25:09 -07:00 committed by Paul Gamble
parent 85412ef12a
commit 88f0996a4f
1 changed files with 26 additions and 0 deletions

View File

@ -229,7 +229,33 @@ int main(void)
return 0; return 0;
} }
``` ```
### Pointer to pointer
In case of pointer to pointer the first pointer is used to store the address of the second pointer, and the second pointer is used to point the address of the variable.
```C
#include<stdio.h>
int main()
{
int p=10;
int *p2;
int **p1; //declaration of pointer to pointer
p2=&p;
p1=&p2;
printf("%d\n",p);
printf("%d\n",*p2);
printf("%d",**p1); // printing using pointer to pointer
return 0;
}
```
#### Output
```
->10
10
10
```
### Constant pointer to constant ### Constant pointer to constant
Above declaration is constant pointer to constant variable which means we cannot change value pointed by pointer as well as we cannot point the pointer to other variable. Above declaration is constant pointer to constant variable which means we cannot change value pointed by pointer as well as we cannot point the pointer to other variable.
```c ```c
#include <stdio.h> #include <stdio.h>