comp.lang.c
[Top] [All Lists]

Re: How does printf() works

Subject: Re: How does printf() works
From: pete
Date: Fri, 28 Mar 2008 22:05:54 -0500
Newsgroups: comp.lang.c

Amandil wrote:
> 
> On Mar 23, 2:07 am, Richard Heathfield <r...@xxxxxxxxxxxxxxx> wrote:
> > Amandil said:
> >
> > <snip>
> >
> > > I only wish I knew how to [plonk] with google...
> >
> > s/with// - i.e. stop using google,
> > and get a real newsreader. (It's the
> > obvious step.)
> I know, but thus far I've been too cheap. Maybe soon. Some good
> (free?) newsreaders were mentioned recently here, I started looking in
> to them.
> 
> > >
> > > On a slightly (but only a very slightly) more serious note,
> > > printf is
> > > probably implemented as a wrapper:
> > > int printf(char *format, ...)
> > > {
> > >     int i;
> > >     va_list v;
> > >     va_start(v, format);
> > >     i = vfprintf(stdin, format, v);
> >
> > ITYM stdout, right?
> 
> Of course, right as usual ;)
> 
> > >     va_end(v);
> > >     return v;
> > > }

... and you really want to return (i) instead of (v), don't you?

I have a version of min_printf in my toy library:
    http://www.mindspring.com/~pfilandr/C/library/std_io.c

minprintf is in K&R.

-- 
pete

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy