I have an exercise where I am required to print a file slowly (1 second intervals) until the file ends, unless the user types a character.
So far, the program output
You'd want to make your program multithreaded. Create a thread that prints out the file every 1 second interval, and your main thread would be getting input from stdin, then signal the other thread to stop printing whenever you get the input