没有合适的资源?快使用搜索试试~ 我知道了~
c++输入文件流ifstream用法详解_ims的博客-CSDN博客1
需积分: 0 8 下载量 2 浏览量
2022-08-03
15:32:33
上传
评论
收藏 3.76MB PDF 举报
温馨提示
试读
11页
c++输入文件流ifstream用法详解_ims的博客-CSDN博客c++输入文件流ifstream用法详解原创阅读数 43446收藏发布于2018-05-18
资源详情
资源评论
资源推荐
1/9/2020 c++输入文件流ifstream用法详解_ims的博客-CSDN博客
https://blog.csdn.net/sinat_36219858/article/details/80369255 1/11
c++输入文件流ifstream用法详解
原创
ims- 阅读数 43446 收藏发布于2018-05-18 20:42:29
目录
输入流的继承关系:
成员函数
Public member functions
1, (constructor)
2,ifstream::open
3,ifstream:: is_open
4,ifstream:: close
5,ifstream:: rdbuf
6,ifstream:: operator =
Public member functions inherited from istream
7,std::istream::operator>>
8,istream::gcount
9,istream::get
10,istream::getline
11,istream::ignore
12,istream::peek
13,istream::read
14,istream::putback
15,istream::unget
16,istream::tellg
17,istream::seekg
Public member functions inherited from ios
18,ios::good
19,ios::operator!
20,ios::operator bool
21,ios::rdstate
输入流的继承关系:
ios_base <- ios <- istream <- ifstream
1
1篇
4篇
15篇
5篇
QQ客服
客服论坛
网络110报警服务
等级: 周排名: 9054
积分: 3439 总排名: 1万+
1篇
1篇
2篇
2篇
篇
2018年9月
2018年6月
2018年5月
2018年4月
展开
c++输入文件流ifstream用法详解
阅读数 43120
matplotlib.pyplot.plot()参数详解
阅读数 36395
python的subprocess.Popen()的简单用法
阅读数 35966
Ubuntu 16.04添加开机启动脚本的方法
阅读数 17362
SMTP协议详解
阅读数 16805
C++矩阵运算类(Matrix.h)
C++矩阵运算类(Matrix.h)
C++递归方法计算n阶行列式
c++输入文件流ifstream用...
Window设置Wifi热点的脚本
kefu@csdn.net
400-660-0108
工作时间 8:30-22:00
关于我们 招聘 广告服务 网站地图
京ICP备19004658号 经营性网站备案信息
公安备案号 11010502030143
©1999-2019 北京创新乐知网络技术有限
公司
北京互联网违法和不良信息举报中心
中国互联网举报中心 家长监护 版权申诉
原创
118
粉丝
71
获赞
92
评论
64
访问
31万+
关注
私信
git 用法
Linux虚拟机与本地机共享文件夹
python处理打卡数据的excel表格
gdb 用法
安装广告拦截插件abp
机器学习
7篇
Python
19篇
linux c++编程
7篇
C++
42篇
SQL
6篇
展开
2019年12月
2019年6月
2019年2月
2018年11月
1/9/2020 c++输入文件流ifstream用法详解_ims的博客-CSDN博客
https://blog.csdn.net/sinat_36219858/article/details/80369255 2/11
C++ 使用标准库类来处理面向流的输入和输出:
iostream 处理控制台 IO
fstream 处理命名文件 IO
stringstream 完成内存 string 的IO
每个IO 对象都维护一组条件状态 flags (eofbit, failbit and badbit),用来指出此对象上是否可以进行 IO 操作。如果遇到错误—例如输入流遇到了文件
象的状态变为是失效,所有的后续输入操作都不能执行,直到错误纠正。
头文件 <fstream> 包含的多个文件流类,这里列出常用的4个:
ifstream Input file stream class (class )链接
ofstream Output file stream (class )链接
fstream Input/output file stream class (class )链接
filebuf File stream buffer (class )链接
成员函数
Public member functions
1, (constructor)
第一种不绑定文件,后续用open() 绑定。
第二种绑定文件 filename ,读取模式默认参数为 ios_base::in可以省略。
2,ifstream::open
打开文件filename,模式默认 ios_base::in
函数参数:
filename 要打开文件的文件名
mode 打开文件的方式
member constant stands for access
default (1) ifstream();
initialization (2)
explicit ifstream (const char* filename, ios_base::openmode mode = ios_base::in);
explicit ifstream (const string& filename, ios_base::openmode mode = ios_base::in);
1
2
3
4
void open (const char* filename, ios_base::openmode mode = ios_base::in);
void open (const string& filename, ios_base::openmode mode = ios_base::in);
1
2
1篇
4篇
15篇
5篇
QQ客服
客服论坛
网络110报警服务
等级: 周排名: 9054
积分: 3439 总排名: 1万+
1篇
1篇
2篇
2篇
篇
2018年9月
2018年6月
2018年5月
2018年4月
展开
c++输入文件流ifstream用法详解
阅读数 43120
matplotlib.pyplot.plot()参数详解
阅读数 36395
python的subprocess.Popen()的简单用法
阅读数 35966
Ubuntu 16.04添加开机启动脚本的方法
阅读数 17362
SMTP协议详解
阅读数 16805
C++矩阵运算类(Matrix.h)
C++矩阵运算类(Matrix.h)
C++递归方法计算n阶行列式
c++输入文件流ifstream用...
Window设置Wifi热点的脚本
kefu@csdn.net
400-660-0108
工作时间 8:30-22:00
关于我们 招聘 广告服务 网站地图
京ICP备19004658号 经营性网站备案信息
公安备案号 11010502030143
©1999-2019 北京创新乐知网络技术有限
公司
北京互联网违法和不良信息举报中心
中国互联网举报中心 家长监护 版权申诉
原创
118
粉丝
71
获赞
92
评论
64
访问
31万+
关注
私信
git 用法
Linux虚拟机与本地机共享文件夹
python处理打卡数据的excel表格
gdb 用法
安装广告拦截插件abp
机器学习
7篇
Python
19篇
linux c++编程
7篇
C++
42篇
SQL
6篇
展开
2019年12月
2019年6月
2019年2月
2018年11月
1/9/2020 c++输入文件流ifstream用法详解_ims的博客-CSDN博客
https://blog.csdn.net/sinat_36219858/article/details/80369255 3/11
member constant stands for access
in input File 读的方式打开文件
out output 写的方式打开文件
binary binary 二进制方式打开
ate at end 打开的时候定位到文件末尾
app append 所有操作都定位到文件末尾
trunc truncate 丢弃打开前文件存在的内容
3,ifstream:: is_open
文件流对象与文件绑定,返回 true ,否则 false 。
4,ifstream:: close
5,ifstream:: rdbuf
返回一个 filebuf 对象指针,(The pointer to the internal filebuf object.)
6,ifstream:: operator =
等号运算符禁止使用左值引用,可以使用右值引用。(即右边的值必须是一个即将销毁的临时对象)
Public member functions inherited from istream
7,std::istream::operator>>
输入终端 cin 和 ifstream 都是 istream 的子类,所以输入操作符 >> 用法相同。对变量进入输入的时候重载了常用的数据类型。
bool is_open() const;
1
void close(); //关闭文件流
1
filebuf* rdbuf() const;
1
copy(1) ifstream& operator= (const ifstream&) = delete;
move(2) ifstream& operator= (ifstream&& rhs);
1
2
arithmetic types (1)
istream& operator>> (bool& val);
istream& operator>> (short& val);
istream& operator>> (unsigned short& val);
istream& operator>> (int& val);
istream& operator>> (unsigned int& val);
istream& operator>> (long& val);
istream& operator>> (unsigned long& val);
istream& operator>> (long long& val);
istream& operator>> (unsigned long long& val);
istream& operator>> (float& val);
istream& operator>> (double& val);
istream& operator>> (long double& val);
istream& operator>> (void*& val);
stream buffers (2)
istream& operator>> (streambuf* sb );
manipulators (3)
istream& operator>> (istream& (*pf)(istream&));
istream& operator>> (ios& (*pf)(ios&));
istream& operator>> (ios_base& (*pf)(ios_base&));
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1篇
4篇
15篇
5篇
QQ客服
客服论坛
网络110报警服务
等级: 周排名: 9054
积分: 3439 总排名: 1万+
1篇
1篇
2篇
2篇
篇
2018年9月
2018年6月
2018年5月
2018年4月
展开
c++输入文件流ifstream用法详解
阅读数 43120
matplotlib.pyplot.plot()参数详解
阅读数 36395
python的subprocess.Popen()的简单用法
阅读数 35966
Ubuntu 16.04添加开机启动脚本的方法
阅读数 17362
SMTP协议详解
阅读数 16805
C++矩阵运算类(Matrix.h)
C++矩阵运算类(Matrix.h)
C++递归方法计算n阶行列式
c++输入文件流ifstream用...
Window设置Wifi热点的脚本
kefu@csdn.net
400-660-0108
工作时间 8:30-22:00
关于我们 招聘 广告服务 网站地图
京ICP备19004658号 经营性网站备案信息
公安备案号 11010502030143
©1999-2019 北京创新乐知网络技术有限
公司
北京互联网违法和不良信息举报中心
中国互联网举报中心 家长监护 版权申诉
原创
118
粉丝
71
获赞
92
评论
64
访问
31万+
关注
私信
git 用法
Linux虚拟机与本地机共享文件夹
python处理打卡数据的excel表格
gdb 用法
安装广告拦截插件abp
机器学习
7篇
Python
19篇
linux c++编程
7篇
C++
42篇
SQL
6篇
展开
2019年12月
2019年6月
2019年2月
2018年11月
剩余10页未读,继续阅读
优游的鱼
- 粉丝: 70
- 资源: 316
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0