views:

310

answers:

2

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++

+12  A: 

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.

Philipp
Works a treat. Thanks
Lodle
+5  A: 

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.

Ben Schwehn