I can not understand the difference in array size of this example:
#include <stdio.h>
int (*foo(void))[3] {
static int array[3] = { 1, 2, 3 };
printf("Dimension inside = %d\n", sizeof(array));
return array;
}
int main(void) {
foo();
printf("Dimension outside = %d\n", sizeof(foo()));
return 0;
}
In particular the first foo() printa one size (12) while the second call of foo() inside sizeof() give me just 4.
Moreover, what is the purpose the declare that the function return a pointer of an array of 3 int? A thing like int *foo(void) would be the same. Right?