C/Language Basics/For Continue — различия между версиями
Admin (обсуждение | вклад) м (1 версия: Импорт контента...) |
|
(нет различий)
|
Версия 17:20, 25 мая 2010
Count spaces in string: how to use continue
<source lang="cpp">
- 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;
}
</source>
For loop with continue
<source lang="cpp">
- 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;
}
</source>