fork download
  1. #include<stdio.h>
  2. int isWhitespace(char c)
  3. {
  4. if(c == ' ')
  5. return 1;
  6. else
  7. return 0;
  8. }
  9. int main()
  10. {
  11. char str[100];
  12. int W = 0, i;
  13. printf("Enter String: \n");
  14. gets(str);
  15. for(i = 0;str[i] != '\0'; i++)
  16. {
  17. W=W+isWhitespace(str[i]);
  18. }
  19. printf("\nWhite spaces: %d",W);
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5316KB
stdin
hello world
stdout
Enter String: 

White spaces: 1