I just found out cd is embedded with the shell, not an actually command
I wrote the following code in my shell program, but it returns me to tell me the dir doesn't exist, what did I do wrong
Code:
char *pcd, *cd;
int i;
pcd = buf; //buf is the shell cmd line input
if ((cd = strstr(pcd, "cd")) != NULL) {
cd += 2;
if ((i = chdir(cd)) !=0) {
perror ("chdir");
}
exit(0);
}