int main(void) { int evil1, evil2; char ch;
do {
printf("Enter a pair of integers:\n");
scanf("%d %d", &evil1, &evil2);
printf("The lesser of %d and %d is %d.\n", evil1, evil2, (evil1 < evil2) ? evil1 : evil2);
printf("Press 'y' to continue,or 'q'to quit.");
while((ch = getchar()) == '\n'); // I don't understand...
} } while (ch == 'y');
printf("Bye.\n");
return 0;
}
while ((ch = getchar()) == '\n'); I don't understand why the code is written like this here.ㅠ<
getchar
Pressing the Enter key is to escape the loop. I think the while door was used twice.
It is called a new line character, so it is marked with "\n".
© 2024 OneMinuteCode. All rights reserved.