Hey guys,
I've had a little experience in C and now I'm taking a small class in C++. There's one project I'm working on in C++ that could have been pretty with the addition of a simple progress bar. I tried it and it didn't work. All that happens is there's a pause (since there are 1 million iterations so I can see the effect) and then the result just blurts out on the screen.
Desired result:
[==== ]20%
turns into:
[======== ]40%
and then 60, 80, and 100%.
However, all I get is:
[====================]100%
without any of the intermediary stuff. I know the "\r" overwrites it, and that's on purpose; however, there should still be enough of a pause between each percentage to see it on the screen.
All that happens is there's a pause (since there are 1 million iterations so I can see the effect) and then the result just blurts out on the screen.
That's because the std::cout buffer doesn't get flushed until the endl on line 26. Use a std::flush I/O manipulator after each "cout" and you'll get the results you expect.