c - What purpose does the declaration "int t[0];" serve? -
what purpose of following declaration?
struct test { int field1; int field2[0]; };
that's 0 length array. according http://gcc.gnu.org/onlinedocs/gcc/zero-length.html:
zero-length arrays allowed in gnu c. useful last element of structure header variable-length object:
struct line { int length; char contents[0]; }; struct line *thisline = (struct line *) malloc (sizeof (struct line) + this_length); thisline->length = this_length;
Comments
Post a Comment