Tuesday, 10 September 2013

How to pass argument got from ellipsis oprator to other function?

How to pass argument got from ellipsis oprator to other function?

void myPrintf(const char* format, ...) {
// some code
va_list vl;
printf(format, vl);
}
int main() {
myPrintf("%d\n", 78);
}
In this code I have tried to pass the argument from ellipsis to printf. It
compiles but prints garbage instead of 78. What is the right way of doing
it.

No comments:

Post a Comment