In C, what is meant by "functions with a variable number of parameters"?
+1
A:
It refers to a function which can take a variable number of parameters using ellipses (...) in the parameter list and va_list, va_start, va_arg etc methods/macros. Do you have a more specific question about it?
See for example:
Hope that helps!
Kieren Johnstone
2010-07-12 09:31:34
Thanks all , but can anybody explain it with a simple example?
Renjith G
2010-07-12 09:40:25
+3
A:
printf
is a nice example of that :)
printf("Call with no other variables");
printf("Call with %d variables", 1);
printf("Call with %d variables. The other variable: %d", 2, 5);
WoLpH
2010-07-12 09:32:11
A:
A function which takes variable number of arguments. Eg printf
The signature is as <return-type> <function-name>(<datatype>,...);
Praveen S
2010-07-12 09:32:27
+3
A:
It means a function that can accept a variable number of arguments:
void myprintf(const char *fmt, ...)
{
}
You can call the above function in any of the below manners:
myprintf("This is %d", 1);
myprintf("%d out of %d", 1, 2);
myprintf("%d/%d %c", 1,2, 'c');
kgiannakakis
2010-07-12 09:33:12
A:
It denotes those functions, which have parameters but the number of parameters are not fixed (hence variable no of params).
Sadat
2010-07-12 09:33:46