O'Reilly logo

C Primer Plus, Fourth Edition by Stephen Prata

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Variable Arguments: stdarg.h

The stdarg.h header file provides a means for defining a function having a variable number of arguments. The prototype for such a function should have a parameter list with at least one parameter followed by ellipses:

void f1(int n, ...);                 /* valid   */
int f2(int n, const char * s, ...);  /* valid   */
double  f3(...);                     /* invalid */

In the following, the term parmN is the identifier used for the last parameter preceding the ellipses. In the preceding examples, parmN would be n for the first case and s for the second case.

The header file declares a va_list type to represent a data object used to hold the parameters corresponding to the ellipses part of the parameter list. Table RS.V.19 lists three macros to be used in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required