Chapter 24. Miscellaneous Topics
Variable length argument lists are referenced, but not completely explained earlier in the book, so they are discussed in this chapter. An example of resource sharing is also presented.
Functions with Variable-Length Argument Lists
In C and in C++ it is possible to define functions that have parameter lists ending with an ellipsis (. . .). The ellipsis allows the number of parameters and their types to be specified by the caller. The usual example of such a function is from <stdio.h>.
int printf(char* formatstr, ...)
This flexible mechanism permits calls such as
printf("Eschew Obfuscation!\n"); printf("%d days hath %s\n", 30, "September"); ...