Pointer losing its value + execv compilation warning

梦想与她 提交于 2019-11-27 16:28:37

C is pass by value. So when doing this

 int searchCmd(char * cmd, char * adrCmd){

adrCmd is a copy of what had been passed in. Overwriting the copy won't change what it had been copied from in the caller.

To fix this pass down the address of adrCmd:

 int searchCmd(char * cmd, char ** padrCmd){

and use it like this:

    *padrCmd = adr;

Call searchCmd() like this:

  if(!searchCmd(splited[0], &adrCmd)){

and define and initialise adrCmd like this;

  char * adrCmd = NULL;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!