I have an array of strings named token declared as follows:
char * token;
I'm reading a line of input from the user, parsing the string and making each index of token contain each word input by the user (I removed the \n at the end too)
My goal is to pass the input to the shell so that it can execute the line entered by the user as though the user had typed them directly into the terminal.
I tried to do this as follows:
but it doesn't work...Code:execv("/bin/tcsh", token);
Let's say I enter ls somedir as the input, then I print out the values of the initialized indices of my array I can see that
token = ls
token = somedir
so I know that the problem isn't that the array isn't being properly initialized...
any ideas why it doesn't work?