I think it's a simple question, but I can't get the answer by myself. I have a struct like this and want to initialize an array of commands.
typedef struct LPWA_COMMAND
{
LPWA_COMMAND_TYPE type;
const char text[];
}LPWA_COMMAND;
LPWA_COMMAND_TYPE is just a simple enum. Don't mind that.
I don't want to give text
a fixed size like: const char text[30]
, since I know every command before compiling the program and it would be a waste of memory.
Since it is possible to do that: const char text[] = "Hi";
there has to be a solution similar to this.
This works:
LPWA_COMMAND test = {
LPWA_EXTRA, "ATI"
};
but this is giving me an error: (initialization of flexible array member in a nested context)
LPWA_COMMAND test2[1] = {
{LPWA_EXTRA, "ATI"}
};
BTW: LPWA_COMMAND has to be a typedef.
Thanks!