I am a little confused as to how I need to allocate memory for a dynamic array inside a struct. Here is the struct that I am using:
typedef struct command_t *commandPtr;
typedef struct command_t
{
char* name;
int argc;
char* argv[];
} commandT;
I declare an instance of the struct as:
commandPtr theCommand;
theCommand = (commandPtr) malloc(sizeof(c ommandT));
So, now I have an instance of the struct. But the argv array is dynamic. How do I now allocate more memory to allow for argv to be any size? Any advice would be appreciated.
Thanks,
skm376
typedef struct command_t *commandPtr;
typedef struct command_t
{
char* name;
int argc;
char* argv[];
} commandT;
I declare an instance of the struct as:
commandPtr theCommand;
theCommand = (commandPtr) malloc(sizeof(c ommandT));
So, now I have an instance of the struct. But the argv array is dynamic. How do I now allocate more memory to allow for argv to be any size? Any advice would be appreciated.
Thanks,
skm376