Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- int main() {
- int lines = 0, wordCnt = 0, chCnt = 0;
- char ch, prev = ' ';
- while ((ch = getchar()) != EOF) {
- if (ch == '\n') {
- lines++;
- }
- if (isspace(ch) && !isspace(prev)) {
- wordCnt++;
- }
- prev = ch;
- chCnt++;
- }
- printf("%d %d %d\n", lines, wordCnt, chCnt);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement