I get "passing argument 2 of ‘execvp’ from incompatible pointer type" and
expected ‘char * const*’ but argument is of type ‘const char **’ I'm wondering what the correct syntax is? Thanks!
int main(int argc, const char* argv[]) {
if(argv[0]!=NULL)
return -1;
开发者_开发问答int pid = fork();
if(pid==0)
execvp(argv[0],argv+strlen(argv[0]));
else
wait();
return 0;
}
exec
functions don't accept const char*
. In your case, simply change argv
to char*
, that's the correct prototype.
Btw. argv + strlen(argv[0])
doesn't make any sense, what did you mean by that?
精彩评论