I have many of them :) At this point I'm looking for help with a specific idea I know is possible, I just have no idea how to pull it off

first some code:

cout << "Would you like to continue? (Y/N);
   //Do stuff
   //Do more stuff

Now let's define what I want from the methods:

method1 - A simple method that accepts one character, as soon as it is hit, without waiting for a newline (or "return") and lets me send it to a char variable to check with, for instance, an if statement.

method2 - A method that checks for a character and allows it to be returned and acted upon in the Do more stuff section. If nothing is there it does different stuff in the do more stuff. Possibly used in a game situation for a real time combat system to check for user input and then go on to calculate some computer player actions.

I'm not too sure if I explained what I want adequately. It makes perfect sense in my head, and I'm sure these methods exist in standard libraries somewhere, I just don't know where.

Thanks for any time you may waste looking at this :)

9 Years
Discussion Span
Last Post by ebmusicman

It sounds like you want the equivalent of getch and kbhit. Search for those two on these forums and you'll find sample code for those functions and alternatives. Keep in mind that what you want to do isn't portable.


When you say portable I assume you mean compiling with g++ pretty much guarantees non-compiling with, for instance, Visual C++ ?


>When you say portable I assume you mean compiling with g++ pretty
>much guarantees non-compiling with, for instance, Visual C++ ?
Something like that.


Oki doke, I'll bang my head against it for a bit more and complain if I get a headache :) Thanks for the help!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.