Advertisement
Forceisthop

Untitled

May 16th, 2022
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include<stdio.h>
  2. #include <fcntl.h>
  3.  
  4. int main()
  5. {
  6. int fd, sz;
  7. char *c = (char *) calloc(100, sizeof(char));
  8.  
  9. fd = open("file.c", O_RDONLY);
  10. if (fd < 0) { perror("r1"); exit(1); }
  11.  
  12. sz = read(fd, c, 10);
  13. printf("called read(% d, c, 10). returned that"
  14. " %d bytes were read.\n", fd, sz);
  15. c[sz] = '\0';
  16. printf("Those bytes are as follows: % s\n", c);
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement