1
2 int main()
3 {
4 int fd; /* for file descriptor */
5 char buffer[1024];
6 int count;
7
8 if ( (fd = open("/home/gal/blob", O_RDWR) == -1 ) {
9 /* couldn't be opened */
10 perror("/home/gal/blob"));
11 exit(1);
12 }
13 if ((count = read(fd, buffer, 1024)) == -1) {
14 /* the read failed */
15 perror("read"); /* or printf("%s\n", strerror(errno)); */
16 exit(1);
17 }
18 /* buffer now contains count bytes that were read from the file */
19 ...
20 }