C++学习 -4 查询C++标准库写应用层代码以filestream【缺少对标准库的解析】

1、查看C++标准库的三个方式
man手册,但Ubuntu默认不安装,需要自己手动安装,但是linux下查看不方便。
两个网址介绍;
英文老但是全;http://cplusplus.com/reference/fstream/basic_fstream/
中文并且更新到20;https://zh.cppreference.com/w/cpp/io/basic_fstream
在这里插入图片描述
在这里插入图片描述

以使用读写文件的filestream为例;
根据C++标准库网页参考编写
注意可能会报错,可使用g++ 3.10Filestream.cpp -std=c++11,使用C++11标准即可使用

#include <iostream>
#include <fstream>
#include <string>

using namespace std;
int main()
{
	string str_fileName = "1.txt";
	
	//原型void open( const char *filename,ios_base::openmode mode = ios_base::in|ios_base::out );
	std::fstream s(str_fileName);//其操作结果不以返回值来返回而是存在在内部用is_open()
	//bool is_open();	若文件流有关联文件,则为 true ,否则为 false 。
	if(!s.is_open())
	{
		cout<<"operator error"<<endl;
	}
	//basic_ostream& write( const char_type* s, std::streamsize count );	
	s.write("1234", 5);
	
	s.close();
	
	return 0;
}

2、缺少大量解析以及其他函数使用案例,之后补充上,因涉及复杂的源码以及模板相关的内容

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值