Count spaces in string: how to use continue : For Continue « Language Basics « C / ANSI-C






Count spaces in string: how to use continue



#include <stdio.h>

int main(void)
{
  char s[80], *str;
  int space;

  printf("Enter a string: ");
  gets(s);
  str = s; 

  for(space = 0; *str; str++) {
    if(*str != ' ') 
        continue;
    space++;
  }
  printf("%d spaces\n", space);

  return 0;
}

  

           
       








Related examples in the same category

1.For loop with continue