1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
| #include <stdio.h>
| #include <errno.h>
| #include <string.h>
| #include <sys/types.h>
| #include <sys/stat.h>
| #include <fcntl.h>
|
| int main(int argc, char **argv)
| {
| char *file_name = "/test.txt";
| int fd=-1;
|
| fd=open(file_name, O_RDONLY, 066);
| if( fd < 0 )
| {
| perror("Open file failure");
| printf("Open file %s failure: %s\n", file_name, strerror(errno));
| return 0;
| }
|
| close(fd);
| }
|
|