linux判断一个文件是否存在

来源:互联网 发布:编程器是什么 编辑:程序博客网 时间:2024/03/29 14:57
  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 }