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);
}
Error: cannot convert from void** to int**
Garbage value
0
No output
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
95 comments Page 9 of 10.

Geetha said:   1 decade ago
void methods always returns zero I think:).

Darshan said:   8 years ago
Thank you all for the given explanation.

Chidananda said:   5 years ago
Default value of global variable is 0.
(2)

Tarun said:   1 decade ago
Thanks shivam for nice explaination.

Ankitradhe said:   1 decade ago
Global variable default value is 0.

Shruthi said:   1 decade ago
Whether *(int*) is same as (int**)?

Zohra said:   1 decade ago
Well explained. Shivam. Thanks.

Viki said:   1 decade ago
Does void pointer returns zero?

Anu said:   1 decade ago
void *vptr;

Is it correct?

Triven Sharma said:   1 decade ago
Shivam is absolutely right


Post your comments here:

Your comments will be displayed after verification.