Sequential-Access Files-程式設計筆記
Chaper 8 Sequential-Access Files
fstream
- ofstream and ifstream is include in fstream
- ofstream: creats and writes files
- ifstream: reads from files
Ex1(Input data to txt):
1 |
|
Ex2(Read from txt):
1 |
|
Reading from a specific line(seekg(), seekp()) Reference: link
name.seekg(0); => reposition the pointer to location 0.
To read a sequential file again, we need to add name.clear() before the seekg.
Telling you the current location(tellg(), tellp())
- Title: Sequential-Access Files-程式設計筆記
- Author: Shih Jiun Lin
- Created at : 2023-01-17 23:00:50
- Updated at : 2023-01-24 01:30:41
- Link: https://shih-jiun-lin.github.io/2023/01/17/Chaper 8 Sequential-Access Files/
- License: This work is licensed under CC BY-NC-SA 4.0.