I need the arguments that were passed to my process when it was started.
This means, of argv[] I need all but the first (which is my process’s name).
I am having trouble copying it, because of it being type char * argv[].
Can anyone give me the gist of how to do it properly, or perhaps a small code snippet. I’d prefer that to banging my head on the wall.
EDIT:
Clarifying my problem:
The key thing is I need all but the first argument of argv. So i can’t just send it off to other processes, as I am actually using it as an argument to execv.
You wrote in a comment “My first program would have the argument list ‘pname otherpname -arg1 -arg2 -arg3’, and I want to use execv to call otherpname with -arg1 -arg2 -arg3.” In that case, the argument list you want to pass to execv is [otherpname -arg1 -arg2 -arg3] … the argument list passed to execv is exactly what otherpname’s main routine will see as argv, and it must include argv[0] which is conventionally the program name. Conveniently, that list is exactly what argv + 1 points to … no need to copy anything.
[edit]
However, you do have the problem of what to pass to execv as its first argument — the file name of the program to exec. Either otherpname needs to be a fully qualified path or you should use execvp, which searches PATH for the program.