int main(int argc, const char * argv[]) {
ofstream testfile_1("test.txt");
if (testfile_1.is_open()) {
// testfile_1<<"This is a line."<<endl;
// testfile_1<<"This is another line"<<endl;
cout<<"input the polynome"<<endl;
string s ;
getline(cin,s);
testfile_1<<s<<endl;
testfile_1.close();
}
string buffer;
ifstream testfile_2("test.txt");
if (!testfile_2.is_open()) {
cout<<"Error opening file"<<endl;
exit(1);
}
while (!testfile_2.eof()) {
getline(testfile_2,buffer);
cout<<buffer<<endl;
}
return 0;
}
C++文件操作小记
最新推荐文章于 2024-03-30 16:33:17 发布