473,324 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

How to execute a loop until a key is pressed.

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
2 4072
kky2k
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
4,677 Expert Mod 4TB
Have a look at this .
Jul 16 '07 #3

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

Similar topics

6
by: Ravi | last post by:
Hi All, I am trying to execute a select statement using the DBI module of perl in a for loop. I am getting a strange behaviour, the select statement is excuting correctly only for the last element...
3
by: pleary | last post by:
I am quite familiar with JavaScript and many other programming languages as I am a programmer for a living. However, I am having a heck of a time figuring out this problem. I would like to have a...
23
by: ern | last post by:
I have a program that runs scripts. If the user types "script myScript.dat" the program will grab commands from the text file, verify correctness, and begin executing the script UNTIL... I need...
1
by: kaiser | last post by:
Hello. I am trying to write a program that continues to read the last line of a txt file until a stop button is clicked. while (ContinueLoop == true ) { while ((LastLine = file.ReadLine()) !=...
6
by: placid | last post by:
Hi all, Im using the cmd module and i have command that loops and keeps on printing text, what i want to be able to do is loop until the user presses a particular key, say Q/q ? I tried the...
70
by: hstagni | last post by:
When i read a key using getchar() inside a loop, the program stops and wait for a key to be pressed. I actually want the program to continue its execution until a key is pressed. Look at this...
4
by: Vijaykumar Dave | last post by:
Here is a program of calculator. I have a proble in loop. When key 1-8 is pressed, it works ok but if any character key is pressed, it goes to infinite loop. will any one help me to correct my...
8
by: gsxg | last post by:
I am new to python, and have written a simple program to read a port via telnet. I would like it to run until any key is pressed. Of course I wouldn't mind requiring a specific keystroke in the...
1
by: Jon Todd | last post by:
Happy holidays all! I'm developing an application and, as a relative newbie to Python, have come across a stumbling block with Tkinter. I'd like to have a button that when pressed executes a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.