I’m trying to write a program which would write on the console at a very specific position in the screen. Say for example from column 20 to column 39.
After each write, the line is “reset” thanks to the \r parameter. This ensures that the line remains static and only the specific fields are updated.
Problem is, i can instruct printf to write from column 0 to 19 without erasing the rest of the line, but it seems i’m not able to instruct printf to write from column 20 onwards without erasing in the process columns 0 to 19.
Is there a (standard) way to do this ?
using something else than printf is possible.
[Edit] I’ve read there is a gotoxy() function in C which is available for windows apparently, and can be emulated in Linux using ncurses. Is there any problem with this function ?
You can try printing as many backspaces (and spaces to clear old text) as needed to position the cursor.
No guarantee it works for you … if it does: no guarantee it works on the other computer 🙂
It works for me, on both Linux and Windows computers