#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main() {
string temp;
ofstream out("out.txt");
//写入
cout << "输入字符开始写入:";
do{
getline(cin, temp);
out << temp << endl;
} while (temp != "end");
//读取
out.close();
ifstream in("out.txt");
cout << "开始读取写入的字符:" << endl;
while (getline(in, temp)) {
cout << temp << endl;
}
in.close();
}
望采纳,谢谢
温馨提示:答案为网友推荐,仅供参考