I suppose you could try setting up an un-named pipe (which returns two
file-descriptors), forking into two processes, and then you have
communication established, since one process can use one file-descriptor,
and the other can use the other file descriptor to communicate with each
other,
then use one process to run the loop, and the other to wait for input...
then, when input happens, get the process to write the input to the pipe...
you can then get the printf'ing process to keep checking to see if there is
a character in the pipe, and if there is, to break out of the loop...
regards
David Buddrige
> -----Original Message-----
> From: Michael Roecken [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, July 17, 1998 10:43 AM
> To: [EMAIL PROTECTED]
> Subject: Get while in a loop
>
> Hi. I was just wondering if there was a function that allows one to
> execute a loop while waiting for input from the keyboard.
>
> The only way I'm used to it is executing the loop with a scanf for example
> inside the loop. But this will pause the loop waiting for input.
>
> Hopefully you understand what I'm saying.
>
> Thanks,
> Mike
>
> Example
>
> while(1)
> printf ("\a");
>
>
> Now while this is looping I want to stop it by exiting with the stroke of
> a single key anytime during this loop. How would this be done.