[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: [LI] C Programming problem
Hi Mrinal,
This is happening because initally all screen (thats a file in Unix remember
!) bound stuff is stored in a buffer.
You are experiencin the buffering effect.
Add this line
fflush(stdout);
after your printf ("Loading..");
and things should run fine.
Regards
Shourya
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.
--
_______________________________________________________________
Shourya Sarcar
Student
Department of Computer Science and Engineering
Jadavpur University
Calcutta, India 700 032
Email : sarcar@xxxxxxxx
Tel : 91-033-471 0477
Address : 364/3 Netaji Subhas Chandra Bose Road
Calcutta , India 700 047
_______________________________________________________________
--------------------------------------------------------------------
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.