There is a struct like this:
struct sdshdr {
int len;
int free;
char buf[];
};
And the result of printf ("%d\n", sizeof(struct sdshdr));
is 8. If I change char buf[]
to char *
, the result would be 16. Why is char buf[]
taking no space here(sizeof(int)
is 4)? When shoud I choose char buf[]
over char *buf
?