I found this question, I should tell what will be the output.
#include <stdio.h>
int main()
{
int i = 10;
int *p = &i;
foo(&p);
printf("%d ", *p);
printf("%d ", *p);
}
void foo(int **const p)
{
int j = 11;
*p = &j;
printf("%d ", **p);
}
I think it shuold be 11 11 11. The answer is 11 11 unefined. I checked with debugger and I found that the printf returns 3, and after the second print p point to that value 3. I don't know why it happens. If someone can explain that would be great. thanks.