|
-
Dec 27th, 2002, 04:41 PM
#1
Thread Starter
<?="Moderator"?>
quit on return. [*resolved*]
hey im trying to make a program that loops though numbers until you hit return, im doing on a console program and im not using cin. Does any one know how this can be done?
Thanks
Last edited by john tindell; Dec 27th, 2002 at 05:08 PM.
-
Dec 27th, 2002, 05:07 PM
#2
Thread Starter
<?="Moderator"?>
Code:
#include <windows.h>
....
for(;;){
if(GetAsyncKeyState(VK_RETURN))
break;
}
...
-
Dec 28th, 2002, 10:09 AM
#3
Guru
Ack... 100% CPU usage.
-
Dec 28th, 2002, 10:30 AM
#4
Why are you writing a console program and not using i/o functions/objects?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 28th, 2002, 03:32 PM
#5
New Member
-
Dec 28th, 2002, 03:48 PM
#6
Thread Starter
<?="Moderator"?>
i just wanted to know how to stop a loop when someone presses a key.
-
Dec 29th, 2002, 04:48 AM
#7
Given that you have a message loop:
Code:
while(g_bRun) {
// ...
}
// WndProc:
case WM_KEYDOWN:
g_bRun = false;
break;
Of course this only works if the loop is in a different thread.
For console apps, this works for me:
Code:
while(GetAsyncKeyState(VK_RETURN) == 0) {
cout << '.';
Sleep(100);
}
cout << "\nDone." << endl;
but it is absolutly not what a console app is intended for.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|