| | |
need a function that woks a little bit like getch
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
•
•
Hello! here is what I wanna do:
I have a while() statement, and inside of it I have some instructions to repeat. My problem is that, I want somehow to stop that loop ONLY when I press a key... I it's kinda like getch() but getch() waits for a keypress.... Any help is appreciatedThanx in advance.
Last edited by WaltP; Dec 2nd, 2006 at 2:01 am.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
> i tried with kbhit() but isnt actually what i was looking for
Did you try
kbhit() doesn't do any reading, it only tells you if there's something there.
Did you try
C++ Syntax (Toggle Plain Text)
if ( kbhit() ) { ch = getch(); }
•
•
Join Date: Oct 2006
Posts: 58
Reputation:
Solved Threads: 0
•
•
•
•
> i tried with kbhit() but isnt actually what i was looking for
Did you try
kbhit() doesn't do any reading, it only tells you if there's something there.C++ Syntax (Toggle Plain Text)
if ( kbhit() ) { ch = getch(); }
C++ Syntax (Toggle Plain Text)
ch = getch();
I want to loop until a key is pressed. Then I want the ability to check that key that was pressed without havin to press it again
It's been a while since I've used kbhit, so don't shoot me i I'm wrong
; but if I remember correct kbhit will only tell you that a key is pressed. By saying
regards Niek
; but if I remember correct kbhit will only tell you that a key is pressed. By saying ch = getch() you will actually get the key that is pressed, so if you want to loop until a char is pressed just use something like: c Syntax (Toggle Plain Text)
while (!(kbhit())); ch = getchar();
regards Niek
Last edited by niek_e; Jan 22nd, 2007 at 11:15 am.
![]() |
Similar Threads
- NASM Int 21 Function 9 Help (Assembly)
- Own getchar function (C++)
- Big Cheese (Game Development)
- encrypt function (ColdFusion)
- Sorting in date order (Visual Basic 4 / 5 / 6)
- The Race (C++)
- Again please someone check my code (C++)
- How to improve program with string compairing? (C++)
- Help with input (C)
Other Threads in the C++ Forum
- Previous Thread: Help with Creating a Command Line Menu
- Next Thread: reading numbers from a text file and putting them into an integer
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets




Thanx in advance. 

