I am writing a program to find roots of a cubic function, however, I am getting my inputs from a separate text file. So, there might be a case where I get something like this:
1 2 3 4
5 6 7 8
9 0 1
There might not be enough variables (which I need 4 of) in order to run the program, so scanf is stuck in an infinite loop waiting for an input. Is there something that can detect this problem. So far I have this worked out, but it doesn't work:
insertCode:#include <stdio.h> #include <stdlib.h> #include <ctype.h> int main() { double a, b, c, d, f, x=50.0; printf("enter:"); scanf("%lf", &d); if(isspace(d)) printf("No input."); return 0; }