I'm new to programming, and I try to program a menu in C++.
I want it to be in a while
loop, breaking when ESC is pressed, but I want the character to be read instantly without having to press Enter.
while (breaker != 27)
{
//menu based on switch(breaker)
}
I found the getch()
function and <conio.h>
header, but people say not to use it because it works only on Windows.
Is there any other method that I can get a character without pressing Enter, and it's multiplatform/meets coding ethic?
My operating system is Windows 11, but I would like to know the solution that works on other systems.