[C] change console output?
Nov 15, 2015 at 8:58pm UTC
I noticed that linux is capable of "updating" the output from console, e.g. when it downloads something, there's a text progress bar, how do I do that in my program? e.g. I have this code
1 2 3 4 5 6 7 8 9
int main()
{
printf("line 1\n" );
printf("line2\n" );
printf("line3\n" );
printf("line 4\n" );
return 0;
}
how do I make it update line2 and line3 to "line 2" and "line 3" ?
or is there a way to clear the console output? another way than printing thousands of new lines
Nov 15, 2015 at 10:41pm UTC
You may use '\r'
to go back to the start of the line and print the updated version.
Nov 15, 2015 at 11:17pm UTC
what if the output is multiline?
Nov 16, 2015 at 12:21am UTC
Then you need to use something like ncurses.
Topic archived. No new replies allowed.