Re: va_arglist

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Maybe this will help?

http://www.cl.cam.ac.uk/cgi-bin/manpage?3+stdarg

Although, I tried nesting some printf-like calls and had no success. Perhaps there's a trick to it?

H.


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

int testB(char *fmt, ...)
{
 va_list ap;

 va_start(ap, fmt);
 printf("%p  ", va_arg(ap, char *));
 printf("%c\n", va_arg(ap, int));
 va_end(ap);

 va_start(ap, fmt);
 vprintf(fmt, ap);
 va_end(ap);

 return(0);
}

int testA(char *fmt, ...)
{
 int rc = 0;
 va_list ap;

 va_start(ap, fmt);
 printf("%p  ", va_arg(ap, char *));
 printf("%c\n", va_arg(ap, int));
 va_end(ap);

 va_start(ap, fmt);
 rc = testB(fmt, ap);
 va_end(ap);

 return(rc);
}

int main(int argc, char *argv[])
{
 testA("Hello, %s%c\n", "World", '!');

 return(0);
}


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux