Variable-Length Argument Lists

15. Variable-Length Argument Lists

15.1I heard that you have to #include <stdio.h> before calling printf. Why?

15.2How can %f be used for both float and double arguments in printf?

15.3Why don't function prototypes guard against mismatchesin printf's arguments?

15.4How can I write a function that takes a variable number ofarguments?

15.5How can I write a function that takes a format string and avariable number of arguments, like printf, and passes them to printf to do most of the work?

15.6How can I write a function analogous to scanf, that calls scanf to do most of the work?

15.7I havea pre-ANSIcompiler,without <stdarg.h>. What can I do?

15.8How can I discover how many arguments a function was actuallycalled with?

15.9My compiler isn't letting me declare a functionthat accepts only variable arguments.

15.10Why isn't"va_arg(argp, float)" working?

15.11I can't get va_arg to pull in an argument of type pointer-to-function.

15.12How can I write a function which takes a variable number ofarguments and passes them to some other function ?

15.13How can I call a function with an argument list built up at run time?


top