常用system函数
直接见代码:
//test3.cpp
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
system("dir"); //显示当前目录的文件目录
system("pause"); //按任意键
system("cls"); //清屏
system("type test1.cpp"); //显示test1.cpp中的内容
system("copy test1.cpp test.cpp"); //复制文件
system("pause");
system("type test2.cpp"); //显示文件test2.cpp中的内容
}
都很好理解,但是在运行之前要注意,代码中test1.cpp ,test2.cpp 源文件,必须包含在test3.cpp工程文件里面,不然编译的时候会报错,说找不到该文件。