This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: Problem with printf
- From: "Sidharth Jandhyala" <sidharth at clarinox dot com>
- To: "'Nick Garnett'" <nickg at ecoscentric dot com>
- Cc: <ecos-discuss at sources dot redhat dot com>, <gokhan at clarinox dot com>
- Date: Wed, 19 May 2004 11:24:30 +1000
- Subject: RE: [ECOS] Problem with printf
- Organization: Clarinox Pty Ltd.
- Reply-to: <sidharth at clarinox dot com>
Hi Nick,
I am still having a problem with the printf. I tried fflush as you
suggested.
//--------------------------------------------------------------------------
# include <stdio.h>
# include <stdlib.h>
int main (int agrc, char * argv[])
{
printf("1.Hello World\n");
printf("Hello fflush");
fflush(stdout);
} //End main
//--------------------------------------------------------------------------
The output I get is
//--------------------------------------------------------------------------
1. Hello world
//--------------------------------------------------------------------------
I have the latest CVS. Any suggestions??
-------------Sidharth
-----Original Message-----
From: nickg@miso.calivar.com [mailto:nickg@miso.calivar.com] On Behalf Of
Nick Garnett
Sent: Tuesday, 18 May 2004 7:02 PM
To: sidharth@clarinox.com
Cc: ecos-discuss@sources.redhat.com; gokhan@clarinox.com
Subject: Re: [ECOS] Problem with printf
"Sidharth Jandhyala" <sidharth@clarinox.com> writes:
> Why has eCos been implemented such that the '\n' must be included at the
end
> of the printf statement. Is there a way to avoid this characteristic. Is
> there a way to flush the print buffers other than looking for the '\n'.
This is standard C library behaviour. The library buffers all output
characters internally until either the buffer is full or, for line
buffered streams, a newline is output. If you want to cause buffered
data to be output before either of those conditions occurs, use
fflush(stdout).
--
Nick Garnett eCos Kernel Architect
http://www.ecoscentric.com The eCos and RedBoot experts
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss