Functions With Variable Number Of Arguments In C

by Peter Jay Salzman <p@dirac.org>

Overview

  1. Declare a special `pointer' variable of type va_list.
  2. Use va_start() to make the va_list point to the the beginning of the argument list.
  3. Use va_arg() to retrieve arguments.
  4. Use va_end() to cleanup when you're done.

Prototypes

void va_start( va_list ap, last );
type va_arg( va_list ap, type );
void va_end( va_list ap );

Important Notes

Next: Sample code