#include <stdio.h>
#include <string.h> // strcmp
// Infinite while(1) Loop
int main() {
char input[64] = "";
printf("Starting infinite while loop. Type 'quit' to exit.\n");
while (1) { // infinite loop
printf("Enter something: ");
scanf("%99s", input);
if (strcmp(input, "quit") == 0) {
printf("Exiting loop...\n");
break;
}
printf("You typed: %s\n", input);
}
printf("Program finished.\n");
return 0;
}
/*
run:
Starting infinite while loop. Type 'quit' to exit.
Enter something: a
You typed: a
Enter something: b
You typed: b
Enter something: a
You typed: a
Enter something: quit
Exiting loop...
Program finished.
*/