Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define EOL '\n'
- int main()
- {
- int count;
- count=0;
- FILE* filept;
- char c;
- filept=fopen("sample.txt","r");
- if(filept==NULL)
- printf("File not found!");
- while(c=fgetc(filept)!=EOF)
- if(c==EOL)
- count++;
- fclose(filept);
- printf("Number of lines: %d", count);
- return 0;
- }
Add Comment
Please, Sign In to add comment