C++: How can I make an infinite loop stop when pressing any key? -
i'm totally new programming , don't have idea other topics saying this. please explain on c++.
you can quit program, there no real way make stop key on basic level.
alternatively can use condition loop, e.g.
int counter = 0; int countermax = 100; while (true && (counter++ < countermax)) { // code here } if (counter >= countermax) { std::cout << "loop terminated counter" << std::endl; // maybe exit program }
Comments
Post a Comment