![]() |
#2
rjsp2019-06-28 18:32
|
#include <string>
#include <iostream>
using namespace std;
int main()
{
ifstream in("hui.txt");
ofstream out("2.txt");
string filename;
string line;
if(in) // 有该文件
{
while (getline (in, line)) // line中不包括每行的换行符
{
cout << line << endl;
out << line << endl; // 输入到2.txt中
}
}
else // 没有该文件
{
cout <<"no such file" << endl;
}
return 0;
}
[此贴子已经被作者于2019-6-30 17:23编辑过]