0
What is the output!.
#include <stdio.h> void main() { int k = 5; int *p = &k; int **m = &p; printf("%d%d%d\n", k, *p, **p); }
6 Réponses
+ 7
athik rehman First of all you need to know this
(*) - Dereference Operator
(&) - Reference/Address Operator
int k = 5
// 'k' is assigned the value 5
int *p = &k
// a pointer variable 'p' is created which holds the address of variable 'k'
//p = &k, k = 5
//*p = 5
int **m = &p
// a double pointer variable is created which holds the address of pointer variable 'p'. The pointer variable 'p' holds the address of 'k'
//m = &p, p = &k, k = 5
//**m = 5
+ 6
athik rehman Corrected the code, guess the output and then check if your guess is correct or not.
#include <stdio.h>
int main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **m);
}
0
Why don't you run it?
0
k, the address of k, and the address where the address of k is stored.
0
but i got compile time error cant understand how?
0
nAutAxH AhmAd can u pls explain once! thanks