[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

RE: [LI] C Programming problem



The reason is : The stdout stream is buffered.
Please explicitly flush this buffer after the printf. Appending a \n causes
a buffer flush to happen.

Prashast Kumar
ICO
NIIT Ltd.
6203389


-----Original Message-----
From: Anand Singh Bisen [mailto:anand.bisen@xxxxxxxxxx]
Sent: Thursday, November 04, 1999 12:24 AM
To: linux-india@xxxxxxxxxxxxxxxxxxxxx
Subject: Re: [LI] C Programming problem


type
 printf("Loading..\n");
then it'll work properly

anand


Mrinal Kalakrishnan wrote:

> Hi,
>
> This particular piece of code behaves differently when compiled with gcc
> (Linux), when compared to Turbo C or DJGPP (in DOS).
>
>         #include <stdio.h>
>
>         void main()
>         {
>                 printf("Loading..");
>                 float i,j;
>                 j=12345.6789;
>                 for (i=0.0;i<50000.0;i+=0.01) j=j*j;
>                 printf("Done\n");
>         }
>
> The expected behaviour would be that "Loading" gets printed, then a delay,
and
> then "Done" gets printed. But, that doesn't happen. Instead, there is a
long
> delay initially, then "loading" and "done" get printed immediately one
after
> the other. However, if I add a newline in the "Loading" string, then it
gets
> printed immediately, followed by the delay.
>
> Anybody faced this problem before - any solutions?
>
> ----------------------------------------------------------------
> Mrinal Kalakrishnan
> mrinal@xxxxxxxxx
> http://listen.to/mrinal
> ----------------------------------------------------------------
> --------------------------------------------------------------------
> The Linux India Mailing List Archives are now available.  Please search
> the archive at http://lists.linux-india.org/ before posting your question
> to avoid repetition and save bandwidth.

--------------------------------------------------------------------
The Linux India Mailing List Archives are now available.  Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.
--------------------------------------------------------------------
The Linux India Mailing List Archives are now available.  Please search
the archive at http://lists.linux-india.org/ before posting your question
to avoid repetition and save bandwidth.