I'm having a little beginner's issue with indirection.
Suppose I have this file:
printf("Enter a number: ");
printf("Total is %d\n", a + b);
Suppose there's another file called input.txt, whose content is simply:
Assuming the executable is called prog, I'd run the program like this:
prog < input.txt
When I first tried it, I expected the program to read 5 from the file and get my own input from keyboard and then add their sum. Turned out it didn't work because I realised that it seems like once we use the < operator, the program will always assume that it is to get inputs from a file, and not from keyboard. My question is: is there anyway to terminate the file reading from a file (once it's done reading) and go back to the user input?
Or, if there's no way to do that, any other alternatives is welcome, as long as it can do what I want (i.e: read stuff from a file and then when it's done, get back to keyboard).