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