I am making a program that can take another program as an argument and run it.
I am using execv() to run the second program, but how can I use argv[] (that comes from the main program, is a char*) as arguments for execv()?
The first element of argv[] is the name of the main program, so I need to start at the second element where the name of the next program is located.
I am thinking there might be different solutions, for example:
- Tell
execv()to start from the second argument - copy the content of
argv[](except first element) to another array and use that - Something with pointers so maybe I can point to the second element and start there
What is the best way to do this? And can I get an example of how to do it?