Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <stdio.h>
- int main(int argc, char *argv[])
- {
- char buf[256];
- int fd;
- FILE *file;
- puts("open()");
- fd = open(argv[1], O_RDONLY);
- if(fd < 0) {
- perror("open");
- return 1;
- }
- while(read(fd, buf, 1) > 0)
- putchar(buf[0]);
- close(fd);
- puts("\nfopen()");
- file = fopen(argv[1], "r");
- while(fread(buf, 1, 1, file))
- putchar(buf[0]);
- fclose(file);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement