int open(const char *pathname, int flags)
int open(const char *pathname, int flags, mode_t mode)
pathname:要打开的文件名(包括路径,缺省为当前路径)
flag:打开标记
常见的打开标记:
O_RDONLY
0_WRONLY
O_RDWR
O_APPEND
O_CREAT
O_NOBLOCK
如果使用了O_CREATE标志,则使用的函数是:
int open(const char *pathname, int flags, mode_t mode);
这时需要指定mode来表示文件的访问权限。
下面是一个例子file_open.c
运行程序结果为