Advertisement
Guest User

reader

a guest
Dec 6th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. FILE *f = fopen("myfile.txt", "r");
  6.  
  7. if (f == NULL)
  8. {
  9. printf("Cannot open file!\n");
  10. return 1;
  11. }
  12.  
  13.  
  14. fseek(f, 5, SEEK_SET);
  15. fseek(f, 1, SEEK_CUR);
  16.  
  17. for (int i=0; i<5; i++)
  18. {
  19. char c = fgetc(f);
  20. printf("Character from file: %c\n", c);
  21. }
  22.  
  23. fclose(f);
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement