944,093 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1018
  • C++ RSS
May 8th, 2007
0

Ideas beyond my skill level

Expand Post »
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:

C++ Syntax (Toggle Plain Text)
  1.  
  2. cout << "Would you like to continue? (Y/N);
  3. method1();
  4.  
C++ Syntax (Toggle Plain Text)
  1. while(someSentinal)
  2. {
  3. //Do stuff
  4. method2();
  5. //Do more stuff
  6. }
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
Similar Threads
Reputation Points: 29
Solved Threads: 0
Newbie Poster
ebmusicman is offline Offline
5 posts
since May 2007
May 8th, 2007
0

Re: Ideas beyond my skill level

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.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
May 8th, 2007
0

Re: Ideas beyond my skill level

When you say portable I assume you mean compiling with g++ pretty much guarantees non-compiling with, for instance, Visual C++ ?
Reputation Points: 29
Solved Threads: 0
Newbie Poster
ebmusicman is offline Offline
5 posts
since May 2007
May 8th, 2007
0

Re: Ideas beyond my skill level

>When you say portable I assume you mean compiling with g++ pretty
>much guarantees non-compiling with, for instance, Visual C++ ?
Something like that.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
May 8th, 2007
0

Re: Ideas beyond my skill level

Oki doke, I'll bang my head against it for a bit more and complain if I get a headache Thanks for the help!
Reputation Points: 29
Solved Threads: 0
Newbie Poster
ebmusicman is offline Offline
5 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Help Please Connect Four Game
Next Thread in C++ Forum Timeline: C++ and data access





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC