I always use "cin >> *" with switch(*), but it need to press enter after i write the variable's value, but if it's only 1 character long i would like to use an "instant" cin, for example i press 4 and i instantly get X message for case '4' without needing to press enter before.
Doing stuff like this relies on examining the keyboard buffer and that is OS dependent. There is a kbhit()/getch() combo that does what you want but it is not strictly "standard."
Sounds like your only way to go is either with something non portable, non standard, or using a third class library. C++ doesn't handle hardware, in this case keyboard, since it doesn't know it exists. That is why there is all of these added features in OS dependent libraries, non standard libraries, like conio.h, and third party libraries.
Honestly, I wouldn't say it's a gross overstatement. The only thing I missed out on was saying Standard C++ doesn't handle hardware, because quite frankly it doesn't. The OS handles it. Non standard libraries and third party libraries handle hardware because they have found ways to do it. If you know an exception to this, by all means, please tell me about it.
getch() is not standard. In fact, nothing in conio.h is standard and it's bad to learn non standard libraries since they can vary on how they act between different systems.
The only thing I missed out on was saying Standard C++ doesn't handle hardware, because quite frankly it doesn't. The OS handles it.
Aren't there OS's / drivers out there written in C++ ?
How would those be written if c++ doesn't handle hardware?
Is that perhaps what Mr. ResidentBiscuit meant - that it doesn't handle it automagically, but it can?
This sounds as if you are trying to make a game, like with the WASD keys, and if this is the case, then you should get a game library. One I like is Allegro, you can get it here: http://alleg.sourceforge.net/download.html
hope this helps!
@NwN
I didn't say C++ wasn't capable of handling hardware. It's just not something that's easy to implement like I believe the OP wants. I know some of the power of C++, and yes, a lot of things are written in C++, but is it pure C++? Doesn't it typically require a lot of external stuff to make it work? I don't know of anything in the standard libraries that would allow anyone to handle hardware without using, at the bare minimum, either an OS dependent or third party library. Maybe I'm lacking some serious understanding in the hardware portion of C++, but I've been told "that can't be done" when it comes to hardware and standard C++.
I never mention that something can't be done, because quite frankly, I'm not sure of what can't be done with C++.