S
S. Nurbe
Hi,
I have programmed a while loop. At the end of this loop I want to stop
it until someone hit a key. When someone hits the right key the loop
shall start again.
Actually I thought this would be easy to do, but when it waits for
input the application apparently works in the background and when I
hit the right key the loop was already processed several times instead
of starting a new loop.
Are the input and the loop working in different threads?
How can I solve this?
part of my code:
int display = 1;
while (display)
{...
display=0;
printf("\nHit 'c' to continue.\n");
input = getchar();
if (input == 'c')
{
display = 1; //start loop again
}
else display = 0;
....
}
Thanks in advance,
S. Nurbe
I have programmed a while loop. At the end of this loop I want to stop
it until someone hit a key. When someone hits the right key the loop
shall start again.
Actually I thought this would be easy to do, but when it waits for
input the application apparently works in the background and when I
hit the right key the loop was already processed several times instead
of starting a new loop.
Are the input and the loop working in different threads?
How can I solve this?
part of my code:
int display = 1;
while (display)
{...
display=0;
printf("\nHit 'c' to continue.\n");
input = getchar();
if (input == 'c')
{
display = 1; //start loop again
}
else display = 0;
....
}
Thanks in advance,
S. Nurbe