void fun(int *p)
{
int q = 10;
p = &q;
}
int main()
{
int r = 20;
int *p = &r;
fun(p);
printf("%d", *p);
return 0;
}
I have an understanding of pointers, however it was my guess that printf should display 10, although the website's compiler and other compiler say the value remains 20.
Can anyone explain why?
Does fun() have an affect on the pointer p? Why or why not?