Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. // Assuming inFile has been used before.
  2. char ch;
  3. char buffer[1000];
  4. size_t pos = 0;
  5.  
  6. ch = fgetc(inFile);
  7. while (ch != EOF) {
  8.     buffer[pos] = ch;
  9.     if (ch == '\n') {
  10.         buffer[pos] = '\0';
  11.         // Reset the position for next usage
  12.         pos = 0;
  13.  
  14.         // At this point, buffer contains the line that is terminated by '\0'
  15.     }
  16.     ch = fgetc(inFile);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement