329,564 views
41 votes
41 votes
How can I pass the variable argument list passed to one function to another function.

User Lawrence Douglas
by
3.0k points

1 Answer

21 votes
21 votes

Answer:

Step-by-step explanation:

#include <stdarg.h>

main()

{

display("Hello", 4, 12, 13, 14, 44);

}

display(char *s,...)

{

va_list ptr;

va_start(ptr, s);

show(s,ptr);

}

show(char *t, va_list ptr1)

{

int a, n, i;

a=va_arg(ptr1, int);

for(i=0; i<a; i++)

{

n=va_arg(ptr1, int);

printf("\\%d", n);

}

}

User Noam Ross
by
2.9k points