, . 7.1, ,
while ( )
;
, .
( 0), . , 0 (). , while. (.. 0), .
, while, ( ), .
, , . , , .
, , , .
. 7.1. :
;
, . , .
continue break (. . 9.2, 9.3).
, .
, . , . :
int count = 0;
char ch = getchar();
while (ch!= \n') {
count++;
ch = getchar();
}
, , ch, :
char ch;
int count = 0;
while ((ch=getchar())!= '\n') count++;
, ch , , ch :
int count = 0;
while (getchar()!='\n') count ++;
1. Esc
while (1) { //
...
if (kbhit() && getch()==27) break;
...
}
kbhit () > 0, , getch () ( Esc 27). if, Esc, break .
.
2. , ,
...
while (!kbhit());
...
7.3. do while
, . 7.1, .
|
|
do
;
while ();
, . , , , , , .
, , .
, Y y (Yes). .
#include <stdio.h>
void main(void)
{
char answer;
do {
puts(" Hello! => ");
scanf(" %c ", &answer);
}
while ((answer=='y')||(answer=='Y'));
}
:
Hello! => Y
Hello! => y
Hello! => d