1. View the three-way
man manual of the C++ standard library , but Ubuntu does not install it by default, you need to install it manually, but it is not convenient to view it under linux.
Two URLs are introduced;
English is old but complete; http://cplusplus.com/reference/fstream/basic_fstream/
Chinese and updated to 20; https://zh.cppreference.com/w/cpp/io/basic_fstream
Take the filestream that reads and writes files as an example; it is
written according to the C++ standard library web page reference.
Note that errors may be reported, you can use g++ 3.10 Filestream.cpp -std=c++11, you can use C++11 standard
#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. There is a lack of a large number of analysis and other function use cases, which will be added later, because it involves complex source code and template-related content