I have a program, my own shell where the first input is command and the 2nd is cmd. Im trying to get cd working but having trouble with chdir function, i have this and it just gives me a segmentation fault and i dont understand why.
while(!strcmp(command,"cd")) // while the first command is cd do the following
{
if(strcmp(cmd,NULL) == 0) //if the 2nd command is null then change cd to home
{
chdir(getenv("HOME"));
}
else // if the 2nd command isnt a null then change directory to whatever the 2nd command says.
{
chdir(cmd);
}
any help?
}