编写程序,将abc.txt的内容复制到xyz.txt文件中。
不懂使用文件 呜
//打开文件需要ofstream和ifstream, 一个是读, 一个是写. 所以, 要复制需要这样:
#include
using namespace std;
int main()
{
ifstream fin("abc.txt");
ofstream fout("xyz.txt");
char data;
if (!fin || !fout)
return 0;
while(!fin.eof())
{
fin>>data;
fout<<data;
}
return 0;
}
#include <fstream>
using namespace std;
int main()
{
ifstream fin("abc.txt");
ofstream fout("xyz.txt");
char data;
if (!fin || !fout)
return 0;
while(!fin.eof())
{
fin>>data;
fout<<data;
}
return 0;
}
#include<iostream>
using namespace std;
int main(void)
{
system("copy E:\\test.txt F:\\aa.txt");
}
ifstream fin("abc.txt");
ofstream fout("xyz.txt");
if (!fin || !fout)
return 123;
fout << fin.rdbuf();
return 0;
}