You can specify a function that has a variable number of parameters. The most
common example is printf() . To tell the compiler that an unknown number of
arguments may be passed to a function, you must end the declaration of its
parameters using three periods. For example, this prototype specifies that func()
will have at least two integer parameters and an unknown number (including 0)
of parameters after that.
int func(int a, int b, ...);
This form of declaration is also used by a function's definition.
Any function that uses a variable number of parameters must have at least one
actual parameter. For example, this is incorrect:
int func(...); /* illegal */
No comments:
Post a Comment