Guest User

Untitled

a guest
Jan 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define EOL '\n'
  4.  
  5. int main()
  6. {
  7. int count;
  8. count=0;
  9. FILE* filept;
  10. char c;
  11. filept=fopen("sample.txt","r");
  12. if(filept==NULL)
  13. printf("File not found!");
  14. while(c=fgetc(filept)!=EOF)
  15. if(c==EOL)
  16. count++;
  17. fclose(filept);
  18. printf("Number of lines: %d", count);
  19.  
  20. return 0;
  21. }
Add Comment
Please, Sign In to add comment