- 论坛徽章:
- 0
|
#include<stdio.h>;
#include<string.h>;
#include<stdarg.h>;
int getVarArg(int a, int b, char * str, ...);
int fun2(va_list ap);
int main()
{
getVarArg(1, 2, "tmpinfo", "first arg", "second arg", "third arg" ;
return 0;
}
int getVarArg(int a, int b, char * str, ...)
{
int ia = a;
int ib = b;
va_list ap;
va_start(ap, str);
fun2(ap);
va_end(ap);
return 0;
}
int fun2(va_list ap)
{
char * t = NULL;
t = va_arg(ap, char *);
while(t != NULL)
{
printf("The var arg = %s\n", t);
t = va_arg(ap, char *);
}
return 0;
}
运行结果:
The var arg = first arg
The var arg = second arg
The var arg = third arg
The var arg = 壜呉t?
The var arg = l?
The var arg = ZY?$
The var arg = ?縈
@珻@
The var arg =
The var arg = P瑗? |
|