int main(int argc, char **argv)
{
char input[150];
char change[2] = "cd";
char *directory;
while(1) {
prompt();
fgets(input, 150, stdin);
if(strncmp(change, input, 2) == 0) {
directory = strtok(input, " ");
directory = strtok(NULL, " ");
printf(directory);
chdir(directory);
perror(directory);
}
if(feof(stdin) != 0 || input == NULL) {
printf("Auf Bald!\n");
exit(3);
}
}
}
当我启动它并输入“cd test”时,我得到“没有这样的文件或目录”。但是有目录“test”。
在 Arch Linux 上运行。