#include <stdio.h>
int main() {
int *a[2]; // an array of 2 int pointers
int (*b)[2];
// pointer to an array of 2 int (invalid until assigned) //
int c[2] = {1, 2}; // like b, but statically allocated
printf("size of int %ld\n", sizeof(int));
printf("size of array of 2 (int *) a=%ld\n", sizeof(a));
printf("size of ptr to an array of 2 (int) b=%ld\n", sizeof(b));
printf("size of array of 2 (int) c=%ld\n", sizeof(c));
return 0;
}
a
是一个由 2 个整数指针组成的数组,所以大小不应该是2 * 4 = 8
?
在 GCC 上测试。