473,378 Members | 1,441 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,378 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 7174
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.