I have a program running a numerical calculations with precision increasing in time. It does so for different values of some parameters. The precision I need for each results depends on the value of these parameters, in a way totally unknown to me.
To get enough precision for each value, I am thinking about a program/loop that would cut a calculation and move on to new values of the parameters if the user hits the keyboard.
Schematically:
//initialise parameters
while( parameters_in_good_range){
while( no_key_pressed){
//do calculation
}
//update parameters
}
On Windows, this program will loop until a keyboard key is pressed :
#include <conio.h>
void main()
{
while (1)
{
if (_kbhit())
{
break;
}
}
}
On linux, have a look at this answer. It tells you how to use ncurses to do what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With