varargs and scanf
Doug Gwyn
gwyn at smoke.BRL.MIL
Thu Feb 2 08:25:30 AEST 1989
In article <1494 at zen.UUCP> vic at zen.UUCP (Victor Gavin) writes:
>The function I was creating required two obligatory parameters and the rest
>were optional. The function was declared
> void foo(va_alist)
I think you mean that was the declaration used in the function definition?
That's not ANSI C in any case. For ANSI C you must use the ",..." form of
declaration/definition for varargs functions. va_alist belongs to the old
<varargs.h>, not ANSI C and <stdarg.h>.
>My problem was that to catch any mistakes in programs which call it I used
>the prototype
> extern void foo(int,int,...);
That's okay. Fix the function definition to have the same shape.
>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.
More information about the Comp.lang.c
mailing list