[TriLUG] Linux C++ Programming Question

Randall Patrick Barlow rpbarlow at eos.ncsu.edu
Thu Sep 22 16:09:20 EDT 2005


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



More information about the TriLUG mailing list