UNIX学习笔记-文件I/O--(creat,close)

来源:互联网 发布:python 跟踪执行过程 编辑:程序博客网 时间:2024/05/21 06:38

 int creat (const char  *pathname,mode_t mode)

该函数可以用open函数来实现:open(pathname,0_WRONLY | O_CREAT | O_TRUNC,mode)

或通过增加O_RDWR来增加读权限。

open(pathname,O_RDWR | O_CREAT | O_TRUNC,mode)

***!!***若通过新创建的文件与现有文件重名,则将以存在的文件覆盖***!!*****

 

int close(int filedes);

filedes参数是通过open或creat函数返回的文件描述符,而不能是文件名!!

原创粉丝点击