Struct with variable array


#1

Is it possible to create an array in a Struct with one of the element in struct is array size with variable size?? I have a struct variable with two element, in which one of the element is an integer ‘var’ and the other element is an array data[var]. Is it possible??

typedef struct {         
     int var;
     char data[var];   // problem
 }packet


#2

Hi @Programmer
Which programming language are you using ?? C or C++ ? In C its possible and in C++ its not.