I’m trying to use execlp(), but keep getting warnings that I’m not sure how to fix
pathPiece is an array of paths to attempt to use in order to find the command.
pathNum is the number of paths there are to try.
void execute(const char *argv, char *path, int argNum, const char **pathPiece, int pathNum){
int i, ret;
for(i = 0; i < pathNum; i++)
if(argNum == 0){
ret = execlp((const char *)&pathPiece[i], (const char *)argv[0], (const char*)NULL);
if(ret == -1)
continue;
else{
break;
}
}
}
warning: cast to pointer from integer of different size
pathPiece is
const char *pathPiece, so pathPiece[i] is a single char. From your description, it sounds like you want pathPiece to be aconst char **instead.