海合会 (GCC) 4.4.6
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct B {
int i;
char *p;
} B_t;
B_t b = {
.i = 10,
.p = NULL
};
int main(int argc, char *argv[])
{
struct B *ptr;
ptr = &b;
ptr->p = (char *) calloc(ptr->i, sizeof(char));
printf("%d,%lu,%lu\n", ptr->i, sizeof(ptr->p), sizeof((ptr->p)[0]));
return 0;
}
$ make
gcc -g -Wall -o test test.c
$ ./test
10,8,1
为什么 ??我期待 10,10,1