c++实现dos命令

来源:百度知道 编辑:UC知道 时间:2024/06/24 10:09:17
用C++编写一个程序,程序运行和ms-dos一样,能识别简单的dos命令

以下程序已编译确认:
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <dir.h>
#include <cstring>
using namespace std;

int main()
{
char old_dir[256];
//getcurdir(0, old_dir);
getcwd(old_dir, 256);
cout<<"在当前目录下建立并进入一个子目录"<<endl;
system("md book");
//system("cd book");
strcat(old_dir,"\\book");
chdir(old_dir);
system("pause");
cout<<"向新建子目录中拷贝文件"<<endl;
system("copy d:\\wangluo\\*.c ");
system("copy d:\\wangluo\\*.exe ");
cout<<"文件列表--\n";
system("dir /w *.*");
cout<<"显示文件内容--\n";
system("type 001.txt");
cout<<"执行文件--\n";
system("W250");
cout<<"退出子目录"<<endl