#include<iostream>
#include<fstream>
#include<string>
using namespace std;
void main()
{
char ch;
fstream openfile("a.txt",ios::out);
openfile<<"aaaaaaaaaaaddddddddddddffffffffffffffffffffsssssuuuuuuuuuus";//写入
openfile.close();
openfile.open("a.txt",ios::in);
while(!openfile.eof())
{
openfile.get(ch);//读出
cout<<ch;
}
cout<<endl;
openfile.close();
}
C++文件读写示例fstream
最新推荐文章于 2024-01-04 20:25:06 发布