1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <fcntl.h>
4 #include <stdio.h>
5 int main()
6 {
7 int fd;
8 fd = open("./file1",O_RDONLY);
9 if(fd == -1){
10 printf(“open file1 failed\n”);
11
12 fd = open("./file1",O_RDONLY|O_CREAT,0600);
13 if(fd>0){
14 printf(“creat file1 success!\n”);
15 }
16
17 }
18
19 return 0;
20
21 }

Linux文件打开及创建
Linux文件打开及创建

相关文章: