Lodle
Lodle

Reputation: 32227

How do i write over the last line in the console?

I want to show a progress bar (like wget) how do i keep writing to the last line in the console?

Windows 7 vis 2005 c++

Upvotes: 7

Views: 3516

Answers (2)

Ben Schwehn
Ben Schwehn

Reputation: 4575

If you need to go back further than the last line and are using native Win API, you can use the SetConsoleCursorPosition method in kernel32.lib.

Edit: GnuWin32 also seems to have a ncurses port if you can live with the dependencies on GnuWin32.

Upvotes: 7

Philipp
Philipp

Reputation: 7659

with carriage-return ("\r") you can jump back to the beginning of the current line. This will only work for terminals which have support for this feature.

After you jumped back you can just print your new status-line.

Upvotes: 16

Related Questions