linux 中open()函数详解及简单实例
发布时间:2020-12-15 05:15:57 所属栏目:安全 来源:网络整理
导读:open()函数创建文件时便捷的权限设置 头文件 #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); 当flags参数包含O_REEAT时,需要对m
open()函数创建文件时便捷的权限设置 头文件 #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); 当flags参数包含O_REEAT时,需要对mode参数进行指定
第三个参数也可用八进制数字代替,比如0644表示-rw-rCrC int fd; fd = open("./a.c",O_CREAT,0644); -rw-r--r-- 1 lyt lyt 0 7月 18 17:12 a.c 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |