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
parent
85412ef12a
commit
88f0996a4f
|
@ -229,7 +229,33 @@ int main(void)
|
|||
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
|
||||
|
||||
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
|
||||
#include <stdio.h>
|
||||
|
|
Loading…
Reference in New Issue