在虚拟机终端输入命令操作,是我们常见也是最基本操作,今天调用system()函数可创造一个假的终端操作窗口
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("请选择文件:\n");
system("ls /home");
char str[100];
while(1)
{
fgets(str,1000,stdin);
printf("[root@localhost 进程练习]# ");
system(str);
}
return 0;
}