Q:

Is it possible to display a printf() statement for a limited amount of time n c?

I'm a beginner at coding and I was instructed to code a text-based game so I am trying to figure out whether it's possible to print out a statement for a limited time only in C and is it also possible to let them input an answer for a limited time as well? The problem is if I print out something, they could scroll up and that's what I'm trying to avoid. If it is possible, please do enter the code or resources that I may use for reference below. Thank you.

A:

Terminals are, by default, designed to emit progressively more and more lines of text in a buffer. Text gets added to the end, and previous lines remain visible (up to the limit of the terminal's configured buffer size).
It is possible to get more of a "GUI" feel by changing terminal modes, and this is usually done using a library like curses or ncurses. This will permit you to show text at specific parts of the window, and remove said text. Upon ending the program, curses "resets" the terminal such that the whole "GUI" disappears (although some terminals will still show the user the "final state" of the GUI if they scroll up a page).
A code example would be a tutorial on how to use ncurses, which is a bit too broad for this medium, but not difficult to find.
Since you're on a beginner course, it's likely that you are being encouraged to do the next best thing, which is either:

"Faking" disappearing text by streaming a carriage return then overwriting the old line with spaces or replacement text (support for this effect varies), or
"Faking" disappearing text by streaming backspace characters (support for this effect varies), or
Not doing it at all but instead just moving on to the next line

In all cases described above except for #3, the responsibility of implementing a "timer" shall be yours.

