954,487 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Ideas beyond my skill level

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);
method1();
while(someSentinal)
{
   //Do stuff
   method2();
   //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 :)

ebmusicman
Newbie Poster
5 posts since May 2007
Reputation Points: 29
Solved Threads: 0
 

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.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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

ebmusicman
Newbie Poster
5 posts since May 2007
Reputation Points: 29
Solved Threads: 0
 

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

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

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

ebmusicman
Newbie Poster
5 posts since May 2007
Reputation Points: 29
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You