I am writing a C program which is to be executed on the Linux terminal. The program goes into an infinite loop and prints five lines over and over again. How do I get the cursor back to the previous lines?
E.g. I want to print the alphabets and replace them every 15 seconds. So, at T=0, output is
sh>./a.out
AA
BB
CC
DD
EE
At T=15, output is
sh>./a.out
FF
GG
HH
II
JJ
I tried to use lseek over STDOUT to make it overwrite the previous text. But I guess the terminal does not support lseek. Do I have to tinker with the driver APIs? Or is there a simpler way to do that?