#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main(){
string c="";
//在文件末尾追加字符串
ofstream SaveFile("file1.txt", ios::app);
SaveFile << "That's new!/n"<<endl;
SaveFile.close();
//读取整个文件到字符串
fstream OpenFile("file1.txt");
char ch;
while(!OpenFile.eof())
{
OpenFile.get(ch);
c=c+ch;
}
cout<<c;
OpenFile.close();
system("pause");
return 0;
}
C++在文件末尾追加字符串,读取整个文件到字符串
最新推荐文章于 2024-07-09 10:22:44 发布