I'm trying to get a while loop to iterate until a key, ideally enter, is pressed.
Specifically, what I want is for a value to continually update and be visible to the user until he presses enter.
Here is the basic code I'm working with, which doesn't work as I'd like it to
while(1){
printf("Press Enter to Continue\n");
printf("Value to Update: %f\n",value_to_update);
usleep(10000);
system("clear");
while(getchar() != '\n'){
continue;
}
};
Thanks. Happy to clarify anything I've said or answer other questions.
I'm not sure how to explain exactly what I'm looking for. I'll try two ways:
1) I want it to do what the following code does, except stop when the user presses enter:
while(1){
printf("Value to Update: %f\n",value_to_update);
usleep(10000);
system("clear");
};
2) I'll enumerate the steps
1) Print the value to update to the screen
2) Wait for N microseconds
3) Did the User Press enter?
3.False) If No: Clear the screen, Go to step 1
3.True) If Yes: Break from loop
I guess this is way way harder than I thought it would be.