int close(int handle);
// 關閉 open() 打開的文件描述符 handle
int read(int handle, void *buf, int count);
// 從 handle 讀取 count 字節到 buf
// 返回:實際讀取字節數;-1 出錯;0 文件結束
int write(int handle, void *buf, int count);
// 將 buf 中 count 字節寫入 handle
// 返回:實際寫入字節數
int lseek(int handle, long offset, int fromwhere);
// 移動文件指針,功能同 fseek()
// fromwhere: 0=文件開頭, 1=當前位置, 2=文件末尾
long tell(int handle);
// 返回當前文件指針位置,功能同 ftell()
| 特性 | 高級 I/O (fopen/fread...) | 低級 I/O (open/read...) |
|---|---|---|
| 緩衝 | 有(用戶態緩衝) | 無(直接系統調用) |
| 可移植性 | ANSI C 標準 | POSIX/Unix 風格 |
| 文件標識 | FILE* | int handle |
| 格式化 | 支持 | 不支持 |
低級 I/O 更接近操作系統,適用於系統編程、需精確控制緩衝或非標準文件操作場景。應用層開發優先使用高級 I/O。