开发者

execvpe argv to parameter matching syntax help needed

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜