#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char command[100];
while (1) {
printf("$ ");
fgets(command,sizeof(command),stdin);
if (strcmp(command, "exit") == 0) {
break;
}
system(command);
}
return 0;
}
在Linux 下 运行程序后按Ctrl + D 就会死循环,Windows则没这个问题