您的位置:首页 > 编程语言 > C语言/C++

C++文件读写示例fstream

2015-05-19 20:35 330 查看
#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();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: