Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. while(pos != -1 && lineCount < 10)
  2. {
  3. if((rState = read(fileDesc, &c, 1)) < 0)
  4. {
  5. perror("read:");
  6. }
  7. else if(rState == 0) break;
  8. else
  9. {
  10. if(pos == -1)
  11. {
  12. pos = lseek(fileDesc, 0, SEEK_END);
  13. }
  14. pos--;
  15. pos=lseek(fileDesc, pos, SEEK_SET);
  16. if (c == '\n')
  17. {
  18. lineCount++;
  19. }
  20. charCount++;
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement