[TriLUG] Linux C++ Programming Question

John Turner jdturner at nc.rr.com
Thu Sep 22 16:14:14 EDT 2005


Try

cout.flush();

John

On Sep 22, 2005, at 4:09 PM, Randall Patrick Barlow 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
>




More information about the TriLUG mailing list