方法一
#include<iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream s("E://in.txt");
ofstream o("E://out.txt");
if (!s.is_open() || !o.is_open())
{
cout << "Error Open" << endl;
}
else
{
string line;
while (getline(s, line))
{
o << line << endl;
}
cout << "OK" << endl;
}
return 0;
}
方法二
#include<iostream>
using namespace std;
int main()
{
freopen("E://in.txt", "r", stdin);
freopen("E://out.txt", "w", stdout);
string line;
while (getline(cin,line))
{
cout << line << endl;
}
return 0;
}