1 #include <stdio.h>
2 #include <fcntl.h>
3
4 int main(void)
5 {
6
7 int fd;
8 fd = open("a1.out", O_RDONLY | O_CREAT | O_EXCL);
9 if (fd < 0)
10 printf("file is exists!");
11 return 0;
12 }
linux判断一个文件是否存在
最新推荐文章于 2023-12-07 14:10:56 发布
本文通过示例代码展示了如何使用C语言结合文件操作、文件创建与权限控制的实践应用,具体涉及到文件打开方式(O_RDONLY|O_CREAT|O_EXCL)与错误处理(fd < 0)。

6858

被折叠的 条评论
为什么被折叠?



