当前位置:网站首页>Xi IO flow
Xi IO flow
2022-07-05 12:08:00 【Banyuanjun 578】
One Concept
One The concept of flow
Unstructured transmission of data
C++ flow ( External input computer , Computer output external , The process of input and output )
C++11 standard :I/O Standard class library
/* I: in Input O: out Output flow : Data flow */
Two Use
fstream Common file operations class
One Common member functions
01 Open file open
| Pattern mark | Applicable to | effect |
|---|---|---|
| ios::in | ifstream fstream | Open file for reading data . If the file doesn't exist , Then there is an error opening |
| ios::out | ofstream fstream | Open file for writing data . If the file doesn't exist , Then create a new file ; If the file exists originally , The original content is cleared when it is opened |
| ios::app | ofstream fstream | Open file , Used to add data at the end . If the file doesn't exist , Then create a new file |
| ios::ate | ifstream | Open an existing file , And will File read pointer Point to the end of the file . If the file doesn't exist , Then there is an error opening |
| ios::trunc | ofstream | When the file is opened, all data stored inside will be emptied , When used alone with ios::out identical |
| ios::binary | ifstream ofstream fstream | Open the file in binary mode . If this mode is not specified , Open... In text mode |
| ios::in | ios::out | fstream | Open an existing file , You can read its contents , You can also write data to it . When the file was first opened , The original content remains unchanged , If the file doesn't exist , Then there is an error opening |
| ios::in | ios::out | ofstream | Open an existing file , Data can be written to it . When the file was first opened , The original content remains unchanged , If the file doesn't exist , Then there is an error opening |
| ios::in | ios::out | ios::trunc | fstream | Open file , You can read its contents , You can also write data to it . If the file doesn't exist , Then create a new file ; If the file exists originally , The original content is cleared when it is opened |
02 Operation file
//1. Judge whether the file is opened successfully
obj.is_open();// Return value
//2. Whether to reach the end of the file
obj.eof();// Return value
//3. write in ️ One character
obj.put('s');
//4. Read ️ One character
char ch = 0;
obj.get(ch);
ch = obj.get();
//5. Move file pointer
/* Parameters : Moving distance , Where to start moving */
/*
1 ios::beg Beginning of file
2 ios::end End of file
3 ios::cur The current position
*/
obj.seekp(2, ios::cur);
//6. Binary read-write file Large and small end storage
/* Write write */
obj.open("test.txt",ios::out);
int num = 0X11223344;
obj.write((const char*)&num,sizeof(int));
obj.close();
/* read read */
obj.open("test.txt",ios::in);
int val = 0;
obj.read((char*)&val,sizeof(int));
obj.close();
cout << hex << "val = 0X-" << val << endl;03 Close file close
3、 ... and Using overloaded << >>
obj.open("test.txt",ios::out);
obj << "HAPPY NEW YEAR!" << endl;
obj << " May you be happy and prosperous " << endl;
obj << "10086" << endl; //
obj.close();
obj.open("test.txt",ios::in);
char str_1[128];
char str_2[128];
int num;
obj >> str_1 >> str_2 >> num >> endl;
obj.close();边栏推荐
猜你喜欢

Hiengine: comparable to the local cloud native memory database engine
![[yolov5.yaml parsing]](/img/ae/934f69206190848ec3da10edbeb59a.png)
[yolov5.yaml parsing]

强化学习-学习笔记3 | 策略学习

pytorch-权重衰退(weight decay)和丢弃法(dropout)

【TFLite, ONNX, CoreML, TensorRT Export】

【pytorch 修改预训练模型:实测加载预训练模型与模型随机初始化差别不大】

Pytorch softmax regression
![[singleshotmultiboxdetector (SSD, single step multi frame target detection)]](/img/c7/8ad64582e09683818171b625769f37.png)
[singleshotmultiboxdetector (SSD, single step multi frame target detection)]

Pytorch weight decay and dropout

Intern position selection and simplified career development planning in Internet companies
随机推荐
Pytorch weight decay and dropout
Liunx prohibit Ping explain the different usage of traceroute
嵌入式软件架构设计-消息交互
How to clear floating?
无线WIFI学习型8路发射遥控模块
[loss functions of L1, L2 and smooth L1]
程序员内卷和保持行业竞争力
【TFLite, ONNX, CoreML, TensorRT Export】
Ncp1342 chip substitute pn8213 65W gallium nitride charger scheme
Redis集群(主从)脑裂及解决方案
Matlab boundarymask function (find the boundary of the divided area)
Which domestic cloud management platform manufacturer is good in 2022? Why?
Sentinel sentinel mechanism of master automatic election in redis master-slave
【load dataset】
The solution of outputting 64 bits from printf format%lld of cross platform (32bit and 64bit)
[mainstream nivida graphics card deep learning / reinforcement learning /ai computing power summary]
12. (map data) cesium city building map
Intern position selection and simplified career development planning in Internet companies
Matlab superpixels function (2D super pixel over segmentation of image)
全网最全的新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀