I hope I haven\'t missed a similar question.
I\'m trying to code a mini-shell of my own, using primitive C functions.
I got something that should work, but I
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;