Passing variable length arguements to another function.

J

junk

Hi,

Given the following function:-

void foo (char *fmt, ...) {
}

I know how to use va_start, va_end etc to process the parameters but is
there an easy way of passing the parameter list onto another function
that also has variable length arguements.

So for example given the function

void bar (char *fmt, ....) {
}

can I call bar from foo such as

void foo (char *fmt, ...) {
bar (fmt, <what goes here>);
}

Thanks
Andy
 
E

Eric Sosman

Hi,

Given the following function:-

void foo (char *fmt, ...) {
}

I know how to use va_start, va_end etc to process the parameters but is
there an easy way of passing the parameter list onto another function
that also has variable length arguements.

This is Question 15.12 in the comp.lang.c Frequently
Asked Questions (FAQ) list

http://www.eskimo.com/~scs/C-faq/top.html
 
K

Krishanu Debnath

Hi,

Given the following function:-

void foo (char *fmt, ...) {
}

I know how to use va_start, va_end etc to process the parameters but is
there an easy way of passing the parameter list onto another function
that also has variable length arguements.

So for example given the function

void bar (char *fmt, ....) {
}

can I call bar from foo such as

void foo (char *fmt, ...) {
bar (fmt, <what goes here>);
}

Thanks
Andy
No. You should call the function bar with a va_list from function foo.

Krishanu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top