In my linux application, I want to update output in same place i.e.. I want to display my output in specific location in screen(console output) ITERATION 1:
first time 'h' should print in 5th ROW 5th COL and 'i' should print in 5th ROW and 6th COL. ITERATION 2:
second time 'h' should print in 5th ROW 5th COL and 'i' should
print in 5th ROW and 6th COL.
nth time 'h' should print in 5th ROW 5th COL and 'i' should print in 5th ROW and 6th COL. Can you please give me simple program?... I think, this program tell you that what I am expecting? #include<stdio.h>
output: r0c0c1c2c3c4c5c6c7c8c9c10.... row->r
But, i need to display this "hi" in same place in screen(console output) output must be:
In short, I want to overwrite "hi". Code: #include<stdio.h>
The \r character will send the cursor back to the beginning of the line without moving it down. (It doesn't clear the line, either.) If you're being given instructions to go a specific line though, this isn't sufficient, since printf can't go anywhere but across or down. You need to somehow tell the terminal what to do. You do this with ANSI escape sequences, which means printing the ESC character followed by a little bit of data. Here's two simple ones. Code: #include <stdio.h> void cls(void)
// clear screen
void gotoxy(int x, int y)
// go to coordinates
int main(void)
This isn't guaranteed to work in all terminals in all circumstances. (I can't think of a modern UNIX terminal it won't work in, but Windows certainly won't like it.)
Have a Linux Problem
Linux Books
Linux Home: Linux System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|