前置知识:./标准IO
详细系统调用请查阅man手册
open()
打开文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| # include <unistd.h> # include <fcntl.> # include <stdio.h>
int main(int argc, char* argv[]) { int fd = open("./dict.txt",O_RDONLY); if(fd==-1) { printf("file open error!"); } close(fd); return 0; }
|
close()
关闭文件
见上述代码