Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- int main(void)
- {
- FILE * file;
- int c;
- int iw = 0;
- int nl = 0, nw=0, nb=0;
- file=fopen("mobydick.txt", "r");
- while (1)
- {
- if (feof(stdin) || ferror(stdin))
- break;
- c=getc(file);
- if (c < 0)
- break;
- nb++;
- if ( c == '\n')
- nl++;
- if (isspace(c))
- iw = 0;
- else if ( iw == 0)
- {
- nw++;
- iw=1;
- }
- }
- printf("%d %d %d\n", nl,nw,nb);
- }
Add Comment
Please, Sign In to add comment