473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

getch() and getche()

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
Apr 3 '06 #1
4 7177
in linux you can use ncurses that already have them
ze**********************@yahoo.com ha scritto:
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

Apr 3 '06 #2
ze**********************@yahoo.com wrote:
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);

Apr 3 '06 #3
Belated thanks to both of you,

James McLaughlin.
May 2 '06 #4
James McLaughlin wrote:
Belated thanks
for what?
to both of you,


both of who?

May 2 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: VivekR | last post by:
Hi, Consider the program snippet below main { .... printf("Enter Choice: "); int choice = getche();
5
by: Justine | last post by:
Hi All, Which is function equivalent to getch/getche of C++. Thanz in Advance, Justine
28
by: srikanth | last post by:
help me out with the subject
9
by: James McLaughlin | last post by:
Hi, Does anyone know if it's possible to write either a getch() (preferably Borland-style) or getche() function in C without it being platform-dependent or otherwise non-standard? If not, can...
6
by: ppravin88 | last post by:
hi guys 'n' gals .. could anyone tell me the difference between getch(); and getche(); and when and where should we use this function... and also wat is the diff between return(); & return(0);...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.