I'm trying to pass a pointer to an array of structs to a function. Then have the function create its own array of structures, populate it with data and then overwright the the old array with the new array.
I'm pretty sure the problem is with occurring when I try to overwrite the memory. I think that I could be either using the wrong method to overwrite the memory(should I be using the memory functions?) or I might be trying to overwrite the wrong thing. I'm not quite sure what I'm doing wrong. If someone could point me in the right direction I would be extremely thankful; I've been pulling the hair out of my head for like three hours now.
Struct:
typedef struct
{
char command;
int argc;
char* argv[];
}cmd;
Code:
int main(int argc, char *argv[])
{
[... irrelevant code]
cmd cmdv[count];
cmd* cmdv_ptr = &cmdv[0];
dissectCmd(cmdstr, cmdv_ptr);
printf("%i", cmdv[0].argc);
return 0;
}
void dissectCmd(char* str, cmd* cmdv)
{
[... irrelevant code]
cmd cmds[count];
int i = 0;
for(i = 0; i < count; i++)
{
cmd next;
next.command = 'u';
next.argc = 100;
cmds[i] = next;
}
cmdv = cmds;
}