return values from function with variable number of arguments
Hi all,
In C/C++ it is possible to create a function that takes a variable number of arguments using the va_list type found in stdarg.h. These arguments can be used as input for the function.
Does anybody know if it is possible to create a function where a variable number of arguments can be used as output. So that each of the arguments gets a new value assigned. I would like to create something like this:
Code:
void CopyResult(int numberArgs, ...) {
va_list argp;
va_start(argp, numberArgs);
for(int i = 1; i < numberArgs; i++) {
//assign argument 'i' here
.....
va_arg(argp, int); }
va_end(argp);
}
}
Using an array is not possible for me. Since I plan to extend the function to not only take a variable number of arguments but also variable types.
return values from function with variable number of arguments [SOLVED]
Hi,
Tried it. And it works brilliantly. Looks so simple, so why couldn't I figure it myself. :rolleyes:
I also used 's' etcetera instead of the ascii value. My presumption was incorrect that this is impossible when the 'switched' variable is an integer.
Thanks for all the help.
[SOLVED]