C/Language Basics/For Continue — различия между версиями

Материал из C\C++ эксперт
Перейти к: навигация, поиск
м (1 версия: Импорт контента...)
 
(нет различий)

Версия 14:20, 25 мая 2010

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;
}


For loop with continue

  
#include <stdio.h>
int main(void) {
  int x;
  for( x = 0; x < 100; x++ ) {
      printf("Before continue.");
      continue;
      printf("%d ", x); /* this is never executed */
  }
  return 0;
}