[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: [LI] C Programming problem
Hi,
In Linux (and I guess most Unixen), the I/O devices are
buffered and strings sent to the screen only when flushed (The
terminal emulation idea may have something to do with it).
You should end all lines(in printf)with a newline(\n) for
flushing it. I have had this problem before...
You could also try fflush() or similar commands also.
If you dont do flushing, you could get other strange results.
I wrote a program a few years back that would print a message and
fork multiple times. I forgot to put the \n to end the message and
a message which should have been displayed only once appeared a few
hundred times(before the m/c crashed). I you have a 4MB machine
lying around, you could also try the same thing.
-
main()
{
int i;
printf("Should appear only once");
for (i = 0; i<10 ;i++) fork();
}
-
Bye,
--vml
Model Engg. College,
Cochin
_______________________________________________________
Are you a Techie? Get Your Free Tech Email Address Now!
Many to choose from! Visit http://www.TechEmail.com
--------------------------------------------------------------------
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.