Jul 21, 2009 at 8:24pm UTC
Well, getch() will do it, but it's not in the standard so its considered a bad practice.
Jul 21, 2009 at 8:54pm UTC
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.
Jul 21, 2009 at 11:07pm UTC
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()
?
Jul 21, 2009 at 11:50pm UTC
getline() by definition will read characters until it encounters a newline (ENTER).
Jul 22, 2009 at 1:15am UTC
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?
Jul 22, 2009 at 11:48am UTC
See my first response. What platform are you using?
Jul 22, 2009 at 7:44pm UTC
I'm using a windows platform...
Jul 23, 2009 at 1:58am UTC
Well, how convenient that the very first example I gave in the link is for the Windows platform.
Good luck!