Here we have two function pointer calls that assigned the returned values to variables in different ways.
int *func()
{
int *i = calloc(2, sizeof(int));
*i = 100;
*(i + 1) = 200;
printf("i address: %pn", i);
return i; // or 0, both represent a null pointer
}
int main()
{
int(*(*x)())[20] = &func;
int *i = (*x)();
int *p = *(*x)();
printf("%dn", *p);
printf("%dn", *i);
return 0;
}
The code outputs:
i address: <some address>
i address: <some address>
100
100
I expected int *p = *(*x)(); printf("%dn", *p);
to raise an error.
Why do these two different calls output the same value?