What’s the C++ Equivalent to _getch()?

What’s the C++ Equivalent to _getch()?

What is the C++ equivalent to _getch()? I need to have program control immediately after any keypress in a DOS-based program.

Unfortunately there is no specification in the C++ language or libraries thatimposes any kind of restriction on buffered/unbuffered input/output. This is sobecause there are so many platforms on which C++ is supposed to work and itwould be impossiable for all of them to support such operating system-specificfeatures.

Your best bet in these cases is to use what ever is available in your OS. Inyour case, if _getch() works, use it.

See also  Using Consumer Trust to Help Build Brands On Major Social Platforms

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist