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 appreciated :) Thanx in advance.
uu666 0
Newbie Poster
Recommended Answers
Jump to PostCreate a thread which will have only getchar. If something pressed then set a bool value in that thread. Of course in while loop will break when the bool value is set.
Jump to PostHello! 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.... …
Jump to Post> i tried with kbhit() but isnt actually what i was looking for
Did you tryif ( kbhit() ) { ch = getch(); }
kbhit() doesn't do any reading, it only tells you if there's something there.
All 9 Replies
andor 25
Posting Whiz in Training
WaltP 2,905
Posting Sage w/ dash of thyme Team Colleague
Salem 5,138
Posting Sage
uu666 0
Newbie Poster
Salem 5,138
Posting Sage
uu666 0
Newbie Poster
amishosh 0
Junior Poster in Training
Nick Evan 4,005
Industrious Poster Team Colleague Featured Poster
Salem 5,138
Posting Sage
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.