Redis-0x13-库函数fopen

1 查询系统手册

shell
1
man 3 fopen

2 库函数

2.1 原型

shell
1
2
3
4
#include <stdio.h>

FILE *
fopen(const char * restrict path, const char * restrict mode);
shell
1
2
3
4
5
6
7
8
9
10
The fopen() function opens the file whose name is the string pointed to by path and associates a stream with it.

The argument mode points to a string beginning with one of the following letters:

“r” Open for reading. The stream is positioned at the beginning of the file. Fail if the file does not exist.

“w” Open for writing. The stream is positioned at the beginning of the file. Create the file if it does not exist.

“a” Open for writing. The stream is positioned at the end of the file. Subsequent writes to the file will always end up at the
then current end of file, irrespective of any intervening fseek(3) or similar. Create the file if it does not exist.

2.2 入参

2个参数都是必填

  • path是文件的绝对路径

  • mode以什么模式打开文件

    • r读

    • w写

    • a追加写

2.3 出参

返回值是文件描述符


Redis-0x13-库函数fopen
https://bannirui.github.io/2024/04/16/Redis/Redis-0x13-库函数fopen/
作者
dingrui
发布于
2024年4月16日
许可协议