Advertisement
rafikamal

Space Count

Jan 25th, 2013
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.20 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     char str[100];
  6.     int i, count = 0;
  7.    
  8.     gets(str);
  9.    
  10.     for(i = 0; str[i] != '\0'; i++)
  11.         if(str[i] == ' ')
  12.             count++;
  13.            
  14.     printf("%d\n", count);
  15.    
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement