Is it possible to transfer list of parameters of a function , to another function?
For example in my functionA I want to call my functionB/functionC (depends on the stat
If you cannot change your functionB, then you have to extract arguments from your functionA
va list:
#include
#include
int functionB(long b, long c, long d)
{
return printf("b: %d, c: %d, d: %d\n", b, c, d);
}
int functionA(int a, ...)
{
...
va_list va;
va_start(va, a);
long b = va_arg(va, long);
long c = va_arg(va, long);
long d = va_arg(va, long);
va_end(va);
return functionB(b, c, d);
}
Maybe there is a way to copy memory of the functionA parameters and call functionB/functionC with a pointer to it? Does anyone have an idea of how it would be possible?
Then it means that you would have to change declaration of your functionB
, functionC
etc. You might as well then change them to accept va_list
instead:
int functionA(int a, va_list args);
int functionC(int c, va_list args);