I am not getting the obvious output (67, 67) for this program. Why I don't get the value of the local variable of a fucntion to which i am passing a pointer. I can pass the value of a variable to a function through pointer , but not receive the value from a function through a pointer.
#include "stdio.h"
void func(int *p)
{
int i= 67;
p = &i;
printf("\nIn func() %d\n",*p);
}
void main(void)
{
int *ptr;
func(ptr);
printf("\nIn main() %d\n",*ptr);
}
Thanks,
Nishant Ghai