I have a program that will be serving as an interface for a test instrument. This program will run from the command line in Windows, and after taking information about the user (just the user's initials and the revision number), will get data from the instrument, display it, and, at the command of the user, save it and print it (to a printer).
When the information is displayed, it must be updated (every second) until the user chooses to save and print. So, here is the structure of this part of my program (all the variables have been declared):
Basically, I need a way to exit that nested while loop when the user presses Enter. I'm not sure how go about this, though, as scanf will pause the loop for a prompt. I need the loop to complete each second.
i = 1;
while(i == 1)
/* Get data from instrument. */
/* Print data, along with message to hit enter to break the loop and save to file. */
/* If the user hits Enter during this time, exit the loop by setting i to 0. */
/* Save to file, send to printer. */
printf ("Press Enter to test again, or q to exit program: ");
scanf ("%c", answer);
if (answer == q) return 0;
Thanks for any insight.