For my project I need to create a shell and I need the input to be in the format char**, so it can be used better with the system calls. Currently I have the following to parse the input.
char **ParseInput(char *args)
{
char **tokenized_args = new char *[MAX_BUFFER_WORDS];
char *token = strtok(args, " ");
int i = 0;
while (*token != '\n')
{
tokenized_args[i] = token;
token = strtok(args, " ");
i++;
}
return tokenized_args;
}
However I keep getting a segmentation fault at tokenized_args[i] = token;
and I can't really figure out why.
Any help is appreciated.