char fl[1]
我查看了几个实例,其中我在以下代码片段中看到了类似的内容。我无法猜测这种结构的用途可能是什么。
struct test
{
int i;
double j;
char fl[1];
};
int main(int argc, char *argv[])
{
struct test a,b;
a.i=1;
a.j=12;
a.fl[0]='c';
b.i=2;
b.j=24;
memcpy(&(b.fl), "test1" , 6);
printf("%lu %lu\n", sizeof(a), sizeof(b));
printf("%s\n%s\n",a.fl,b.fl);
return 0;
}
输出 -
24 24
c<some junk characters here>
test1