Hi,
In the following code, I am passing a void pointer by reference assigning a value to it. But the value is not reflected in the main program.
It's printing a garbage value. Please tell me what is the correct way of passing a void pointer by reference and getting a value in it from the function.Code:#include<stdio.h> void function(void *p) { int i=9; int *a=&i; p=(void *)a; } int main() { int *p; p=(int *)malloc(sizeof(int)); function((void *)p); printf("%d",*p); return 0; }
Thanks in advance!