// Infinite while(true) Loop
#include <iostream>
#include <string>
int main() {
std::string input;
std::cout << "Starting infinite while loop. Type quit to exit.\n";
while (true) { // infinite loop
std::cout << "Enter something: ";
std::cin >> input;
if (input == "quit") {
std::cout << "Exiting loop...\n";
break;
}
std::cout << "You typed: " << input << "\n";
}
std::cout << "Program finished.\n";
}
/*
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.
*/