#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char *pathname, int flags);
int open(const char *pathname, int flags, mode_t mode);
参数:
pathname: 文件路径
flags: 打开文件的方式
mode: 设置文件属性
返回值:
return the new file descriptor, or -1 if an error occurred and errno is set appropriately.
int creat(const char *pathname, mode_t mode);
参数:
pathname: 文件路径
mode: 设置文件属性
注意: creat() is equivalent to open() with flags equal to O_CREAT|O_WRONLY|O_TRUNC.
也就是creat时候相当于 open中使用了O_CREAT|O_WRONLY|O_TRUNC 组合
#include <unistd.h>
int close(int fd);
参数:
fd: open 返回成功的文件描述符。
返回值:
return : close() returns zero on success. On error, -1 is returned, and errno is set appropriately.