C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 6)
6.
What will be the output of the program ?
#include<stdio.h>
void fun(void *p);
int i;
int main()
{
void *vptr;
vptr = &i;
fun(vptr);
return 0;
}
void fun(void *p)
{
int **q;
q = (int**)&p;
printf("%d\n", **q);
}
Discussion:
95 comments Page 10 of 10.
Mangesh said:
1 decade ago
Because global veriable is set to 0 (by defult).
Preethi said:
1 decade ago
What does this line mean actually?.
q = (int**) &p;.
Can anyone explain me please?.
q = (int**) &p;.
Can anyone explain me please?.
Shashank said:
1 decade ago
The value refer to the pointer p& as the q refer to the extern variable, so the value is 0.
Abs said:
1 decade ago
Because i is declared as extern and the default value of an extern variable is 0 ... i think :)
Sumit said:
2 decades ago
Please explain, how "0" will be displayed???
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers