SilverScreen Solid Modeler

va_arg

va_arg

Previous topic Next topic  

va_arg

Previous topic Next topic JavaScript is required for the print function  

StandardCLibrary

 

<data type> va_arg( va_list args, <data type> )

 

va_list args;           /* variable argument list */

<data type>;            /* next argument data type */

 

 




Synopsis

#include "stdarg.h"

 

The va_arg macro retrieves an argument of type <data type> based on the value of the va_list variable.

 

 

Parameters

args is the address of a va_list , used to hold the current location in a list of unnamed parameters. t is a data type (i.e. int , double *, etc.) that is the data type of the next argument in the argument list.

 

 

Return Value

va_arg returns a value of the data type specified by t .

 

 

Comments

The stdarg facility provides support for accessing unnamed arguments in functions with variable argument lists. The variable argument macros depend on the data type va_list (typedef'd from a char *), defined in stdarg.h, a variable of which may be used to step through the unnamed arguments.

 

 

See Also

va_start , va_end

 

 

Example

C / C++ Code

 

 /* multicat: concatenate strings -- the last string must be NULL */

 void multicat( char *s1, ... )

 {

 va_list args;

 char *s2;

 

 va_start(args,s1);                 /* initialize va_list variable */

 while ( s2 = va_arg(args,char *) ) /* step through args */

    strcat( s1, s2 );

 

 va_end(args);                      /* close out arg processing */

 }