Struct with variable array

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

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

1 Like