[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


Variable arguments for functions

The stdarg.h header file allows the creation of functions that accept a variable number of arguments.

A variable-length argument function is defined with an ellipsis (...) as its last argument. For example:


  int funnyfunc(int a, char c, ...);

The function is written using the va_list type, the va_start(), va_arg() and the va_end() macros.

The function has a va_list variable declared within it to hold the list of function arguments. The macro °"va_start" initializes the va_list variable and is called before gaining access to the arguments. The macro "va_arg" returns each of the arguments in va_list. When all the arguments have been processed through va_arg(), the macro "va_end" is called to allow a normal return from the function.


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000