By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

How to execute a loop until a key is pressed.

P: 1
hi everyone,
ive been asked to write a C code in which there is a while loop that keeps executing till a key is pressed..
ex
while(1)
{
printf("!");
}
now ! shd keep printing till i press a key .how do i do that?
Jul 16 '07 #1
Share this Question
Share on Google+
2 Replies


kky2k
P: 34
hi everyone,
ive been asked to write a C code in which there is a while loop that keeps executing till a key is pressed..
ex
while(1)
{
printf("!");
}
now ! shd keep printing till i press a key .how do i do that?
Use do..while()..instead of while()..and learn abt kbhit()..But it won't work for all the compilers..
Jul 16 '07 #2

sicarie
Expert Mod 2.5K+
P: 4,677
Have a look at this .
Jul 16 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.