[lug] variable args

Holshouser, David dholshou at ball.com
Fri May 4 13:36:03 MDT 2001


FYI

Calling va_arg(ap, va_list) only seems to return the first argument in the
original list. 
And it turns out that I can't use vprint (or printf for that matter). 
Back to the drawing board.

The following code produces:
1 2 3
1 1627655920 144


#include<stdio.h>
#include<stdarg.h>

void test(char *fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    vprintf(fmt, ap);
    printf( fmt, va_arg( ap, va_list ) );
    va_end(ap);
}

int main (void)
{
    test("%d %d %d\n", 1, 2, 3);
}

--
David Holshouser
Engineer I
Ball Aerospace & Technologies Corp.
(303)939-5085  dholshou at ball.com  




More information about the LUG mailing list