getch() and getche()

G

Guest

Hi,

Does anyone know if it's possible to write either a getch()
(preferably Borland-style) or getche() function in C++ (I've posted
the C equivalent of this question to CLC) without it being
platform-dependent or otherwise non-standard?

If not, can someone suggest a good alternative for situations where
you require the user to "press any key to continue" or "press Enter to
continue" - with getch(), the mistakes that a user can make with
getchar() and the like just don't occur.

Thanks,

James McLaughlin
 
E

ehilah

in linux you can use ncurses that already have them
(e-mail address removed) ha scritto:
 
R

red floyd

Hi,

Does anyone know if it's possible to write either a getch()
(preferably Borland-style) or getche() function in C++ (I've posted
the C equivalent of this question to CLC) without it being
platform-dependent or otherwise non-standard?

If not, can someone suggest a good alternative for situations where
you require the user to "press any key to continue" or "press Enter to
continue" - with getch(), the mistakes that a user can make with
getchar() and the like just don't occur.

"Hit any key to continue" is not doable in Standard C++.

"Hit Enter to continue" is doable:

// #includes and surrounding code redacted
std::cout << "Press <Enter> to continue: ";
std::string trash;
std::getline(std::cin, trash);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top