![]() |
| | #1 |
| Registered User Join Date: Feb 2009
Posts: 22
| Code: while(1)
{
if m=1
cout << "lol";
}
while(1)
{
if get_key(space)
m=1;
else
m=0;
}
remember this is just a example! |
| vrkiller is offline | |
| | #2 | ||
| C\C++ beginner Join Date: Nov 2007 Location: Somewhere nearby,Who Cares?
Posts: 375
| would you please explain more! ? it somehow vague to me !(an possibly the others) you mean you are planning to make an infinite loop?
__________________ Highlight Your Codes Quote:
Quote:
| ||
| Masterx is offline | |
| | #3 |
| CSharpener Join Date: Oct 2006
Posts: 5,242
| it seems you'd like to do 2 things simultaneously. two ways: 1. use threads 2. use asynchronous processing (for example timers)
__________________ If I have eight hours for cutting wood, I spend six sharpening my axe. |
| vart is offline | |
| | #4 | |
| The larch Join Date: May 2006
Posts: 3,082
| Or perhaps you could use non-blocking input (OS-specific).
__________________ I might be wrong. Quote:
| |
| anon is offline | |
| | #5 |
| Algorithm Dissector Join Date: Dec 2005 Location: New Zealand
Posts: 2,476
| So is your goal to write 'lol' while the spacebar is held down? If so, you need to use an input method that doesn't wait for you to press a key, but instead just returns the answer immediately telling you if the key is currently down or not. That's "non-blocking input". Then you only have one loop. Pseudocode: Code: while (true)
{
if (key_is_down(KEY_SPACEBAR))
cout << "lol";
}
__________________ My homepage Advice: Take only as directed - If symptoms persist, please see your debugger |
| iMalc is offline | |
![]() |
| Tags |
| c++, loops, thread, time, vrkiller |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Representing floats with color? | DrSnuggles | C++ Programming | 113 | 12-30-2008 09:11 AM |
| need help in time zone | Gong | C++ Programming | 2 | 01-03-2007 04:44 AM |
| Help with assignment! | RVDFan85 | C++ Programming | 12 | 12-03-2006 12:46 AM |
| calculating user time and time elapsed | Neildadon | C++ Programming | 0 | 02-10-2003 06:00 PM |
| time class | Unregistered | C++ Programming | 1 | 12-11-2001 10:12 PM |