I am trying to write a code to read input from the console continuously and update a variable in the application. But if we use scanf function, whenever the function hits it expects an input from the user through console and continues with further instruction only if it receives an input from the console, otherwise it waits unconditionally.
My code is something like
int x, y;
while(1)
{
scanf("%d", &x);
y = x;
----
----
//Remaining code for execution
}
My expectation is the application should not be waiting for input from the console. If the user enters some input in the console, it should read and use that input, otherwise even if no input is entered, the application should execute remaining instructions or it should use the old values. Is there any other way to write such code without using scanf? Thanks!