Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6.     char ch[1000];
  7.     int line=0,word=0,character=0,i;
  8.     while(gets(ch))
  9.     {
  10.         int len = strlen(ch);
  11.         for(i=0; i<len; i++)
  12.         {
  13.             if(ch[i]==' ')
  14.             {
  15.                 word++;
  16.             }
  17.             else
  18.             {
  19.                 character++;
  20.             }
  21.         }
  22.         word++;
  23.         line++;
  24.     }
  25.     printf("characters %d , words %d , lines %d\n",character,word,line);
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement