On Thu, 24 Jun 2004 16:45:44 +0100, Allan Bruce wrote:
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:9W*****************@ord-read.news.verio.net... H?vard Sj?voll wrote: > Anyone got any code for how to print a progressbar in a console-window?
>
> That is, - something like
>
> "Loading: X%"
>
> where X is continousely updated.
Something like
std::cout << "\rLoading: " << Xvalue << '%';
The behaviour of your terminal when \r is printed to it is of course
OS-specific, but it usually works the way you want it.
Don't forget to print 'std::endl' when you're done to move to the next
line.
Victor
If this doesnt work, another way I found was to use several \b - so
basically:
for (int i=0; i<LengthOfProgressInChars; i++)
std::cout << "\b";
std::cout << "\rLoading: " << Xvalue << '%';
<platform-specific behaviour>
Watch it with that. If you go too far backwards, some versions of Windows
(NT-based ones) will bluescreen spectacularly.
<http://homepages.tesco.net/~J.deBoynePollard/FGA/csrss-backspace-bug.html>
</platform-specific behaviour>
--
Some say the Wired doesn't have political borders like the real world,
but there are far too many nonsense-spouting anarchists or idiots who
think that pranks are a revolution.