Pressing buttons to continue

Hello, i've been curious to know...
i've seen programs where it says:
Please press shift to continue

or:
Do your wish to continue? (press y/n)


Basically, my real question is,
how do you make a program where you press a certain button without pressing enter or actually needing to input text or something?

Well, getch() will do it, but it's not in the standard so its considered a bad practice.
It depends on the key you want to react to and what your platform is.

getch() probably won't work if you are looking for shift/alt/ctrl/caps lock keys because those
keys are not passed to the user application by the OS.

For other keys, it depends on the platform.

For unix, for example, you can turn off line buffering on stdin via termios.
so your saying the the code i would use to do that would depend on the platform of your pc?



and also, can you do what i was talking about in my question using
getline() ?


getline() by definition will read characters until it encounters a newline (ENTER).


well then how does this work?

isn't there like a default code used for this stuff... or does it depend on what key I want the user
press?
See my first response. What platform are you using?
See also
http://www.cplusplus.com/forum/articles/7312/page1.html#msg33734

The first part of the article also covers NCurses and conio...

Basically, what you want to do is turn off line-buffered input.

Hope this helps.
I'm using a windows platform...
Well, how convenient that the very first example I gave in the link is for the Windows platform.
Good luck!
Topic archived. No new replies allowed.