69,371
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string path;
int w()
{
char y[] = "]\n";
char z[] = "[";
ofstream out( path.c_str() );
string s = "yyyyyyyyy";
out.write(z,strlen(z));
out.write(s.c_str() , strlen(s.c_str()));
out.write(y,strlen(y));
out.write(s.c_str() , strlen(s.c_str()));
out.close();
return 0;
}
int r()
{
ifstream in( path.c_str() );
string s = "";
getline(in,s);
cout<<s<<endl;
getline(in,s);
cout<<s<<endl;
return 0;
}
int main()
{
path = "ydc.txt";
w();
r();
return 0;
}