This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Flushing output before \n


Hello,

I am having trouble in flushing a line of text before a new
line character (\n) is output.

For example, I have :

   cout << "Reading file...";
   ReadFile();
   cout << "\b\b\b - " << n << " records.\n";

The text from the first "cout" is not output until the second
"cout" is executed, because the first "cout" does not terminate
the line with a new line (\n) character.

I would like the first "cout" to be output when executed so
that is would be visible while the "ReadFile()" operation is
taking place.

I have tried using "system ("stty raw -echo")" before the first
"cout" and "system ("stty -raw echo")" after the last one, as
well as some other parameters of the "stty" command, but none
of these did achieve the desired result; the output of the first
"cout" instruction is still only seen after the new line character
is output by the second "cout".

Has anyone encountered this problem and has found a solution?

Sincerely,

Michel Ducharme.
 ___________________________________________________________________________
|   ______                                    |                             |
|  / / / /  Michel Ducharme                   | Service de l'informatique   |
| /_/_/ /   Analyste en informatique          | Université du Québec à Hull |
|    /_/    (administrateur du réseau Sun)    | 101, rue St-Jean Bosco      |
|           Tel.: (819) 595-3900 poste 1-1615 | Hull (Québec) J8Y 3G5       |
|           FAX:  (819) 773-1699              | Canada                      |
|           Courrier électronique  : Michel_Ducharme@UQAH.UQuebec.CA        |
|           Site Web du réseau Sun : http://w3.UQAH.UQuebec.CA              |
|___________________________________________________________________________|


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]