Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<ctype.h>
- int wordcount()
- {
- int c;
- int word_cnt=0;
- int char_cnt=0;
- int lines_cnt=1;
- while((c=getchar() )!=EOF)
- { char_cnt++;
- if(isspace(c))
- { if( !isspace((c=getchar())))
- word_cnt++;
- ungetc(c, stdin);
- }
- else if(c=='\n')
- lines_cnt++;
- }
- printf("No. of chars: %i, No. of words:%i, No. of lines:%i", char_cnt, word_cnt,lines_cnt);
- }
- int main()
- {
- wordcount();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement