varargs and scanf

Joe English jeenglis at nunki.usc.edu
Mon Feb 6 15:47:25 AEST 1989


gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>In article <1494 at zen.UUCP> vic at zen.UUCP (Victor Gavin) writes:
[...]
>>My other problem is that there isn't a varargs version of scanf(). Is there
>>one in ANSI C or is it something that only I would find useful?
>
>No, v*scanf() are not in the proposed ANSI C Standard.  In fact there
>was considerable sentiment for removing the normal *scanf() functions.
>
>I'm not sure how useful v*scanf() would be; I've never felt the need
>for it, though.

Are v?printf also not in the standard?  I've used vsprintf
a couple of times (on the apparently mistaken assumption
that it would be portable across compilers).  It's
proven useful when I wanted to use printf-style output
with a non-file output object. (For example, in a window
package for IBM PCs).

Is there a way to do the following in ANSI-conformant C:

void winprintf(struct WINDOW *w,char *fmt,...)

{
   va_list ap;
   char buffer[BIGNUMBER];

   va_start(ap,fmt);
   vsprintf(buffer,fmt,ap);
   va_end(ap);

   winputstring(w,buffer);
}


--Joe English

  jeenglis at nunki.usc.edu



More information about the Comp.lang.c mailing list