If you want it to flush the buffer, you need to either add a std::endl or std::ends to the end of std::cout <<. Otherwise, as you saw, it will buffer everything. Note, btw, that I'm not for certain ends will work. You may need to do endl, or look into how to flush the buffer. Make sure, however, that you use the c++ iostream functions and not the stdio.h functions (like fflush).
Cheers, Tanner On 9/22/05, Randall Patrick Barlow <[EMAIL PROTECTED]> wrote: > I wrote a console based program under Windows, and I then compiled the > same code with g++ under Linux. The program is supposed to output to > the screen the percentage done periodically, so the user has some idea > if the program will take minutes, hours, days, etc. In Windows, this > works great. However, in Linux, it doesn't seem to get written to the > screen every time I cout, as if there were some kind of buffer that were > filling up and waiting to get to a certain level before dumping to the > screen (under bash). The line of code that writes to the screen is > something like: > > cout << '\r' << [code to determine percentage done] << "% complete"; > > Any ideas why I don't see this all the time? It does eventually come > out, but nothing until it's written several times. I even have an > initial line that is supposed to write 0% done, and that never shows up > (but does in Windows). It's no big deal, but it does bug me :) > > Thanks, > Randy > -- > TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug > TriLUG Organizational FAQ : http://trilug.org/faq/ > TriLUG Member Services FAQ : http://members.trilug.org/services_faq/ > TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc > -- Tanner Lovelace clubjuggler at gmail dot com http://wtl.wayfarer.org/ (fieldless) In fess two roundels in pale, a billet fesswise and an increscent, all sable. -- TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug TriLUG Organizational FAQ : http://trilug.org/faq/ TriLUG Member Services FAQ : http://members.trilug.org/services_faq/ TriLUG PGP Keyring : http://trilug.org/~chrish/trilug.asc
