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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -