64,670
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
fstream file("a.txt",ios::out|ios::in|ios::trunc);
file << "Data of test!" << endl;
string str;
file >> str;
cout << "str=" << str << endl;
return 0;
}
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
fstream file("a.txt", ios::out | ios::in | ios::trunc);
file << "Data of test!" << endl;
fstream read("a.txt");
string str;
read >> str;
cout << "str=" << str << endl;
return 0;
}