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

c++语言的本地磁盘的读写

2017-05-18 11:48 435 查看
#include "stdafx.h"
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
//输出到磁盘
//打开文件
ofstream ofs("a.txt", ios::out);
ofs << "this is out!!" << endl;
ofs << "this is out!!" << endl;
//关闭文件
ofs.close();
//输入到程序
ifstream ifs("a.txt",ios::in);
char buf[80];
while (!ifs.eof())
{
ifs.getline(buf, 80);
cout << buf << endl;

}

ifs.close();
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c++ 磁盘读写