In my C program, I use the strtok() command to loop through all the tokens in a string. At each iteration it gives me a pointer to each token.
How can I store the pointers in an array such that the array is like the argv argument in the main function and can be used in the execvp command?
You can do that by creating a vector of pointers to strings if you know how many toks you gonna get. Otherwise, you’ll need to use dynamic structures.
If you know the size, something like this will work:
For dynamic implementation you should go read some documentation/tutorials (1/2/3)
But a struct like this would be the way I’ll do it:
Hope this helps.