C++ 通過 I/O 流庫實現數據輸入輸出。流分為輸出流(內存→設備)和輸入流(設備→內存)。操作步驟:打開流關聯文件 → 讀寫 → 關閉流斷開關聯。
cout:標準輸出流(默認顯示器),使用插入運算符 <<。cin:標準輸入流(默認鍵盤),使用提取運算符 >>。<iostream>(現代標準不帶 .h)。<iomanip>)


ifstream ifile; // 輸入文件流
ofstream ofile; // 輸出文件流
fstream iofile; // 輸入輸出文件流
void open(const char* filename, int mode, int access = filebuf::openprot);
mode:打開模式(ios::in, ios::out, ios::binary, ios::app, ios::trunc 等,可用 | 組合)。access:文件屬性(0 普通、1 唯讀、2 隱藏、3 系統)。
void close(); // 無參數、無返回值

get()、getline()、read()、operator>>put()、write()、operator<<