![]() Chapter Contents |
![]() Previous |
![]() Next |
| va_start |
| Portability: | ISO/ANSI C conforming |
| SYNOPSIS | |
| DESCRIPTION | |
| RETURN VALUE | |
| CAUTION | |
| EXAMPLE | |
| RELATED FUNCTIONS | |
| SEE ALSO |
| SYNOPSIS |
#include <stdarg.h> void va_start(va_list ap, arg_name);
| DESCRIPTION |
va_start
initializes processing of a varying-length argument list. The first argument,
ap
, is a work area of type
va_list
, which is used by the expansions of the various
<stdarg.h>
macros. The second argument,
arg_name
, is the name of
the parameter to the calling function after
which the varying part of the parameter list begins.
va_arg
|
accesses an argument from a varying-length argument list. |
va_end
|
ends varying-length argument list processing. |
These macros and the type
va_list
are defined in the header file
<stdarg.h>
.
The type
va_list
defines a buffer that is used as a work area during argument list processing.
A routine that accepts a varying number of arguments must declare an
auto
variable of this type.
In general, a function that uses the
<stdarg.h>
facilities has this form:
#include <stdarg.h>
/* The arguments in the list are the ones that must */
/* always be present. */
func(type arg1, type arg2)
{
va_list ap; /* Declare stdarg work area. */
/* Note that first varying-length argument */
/* follows arg2 in the list. */
va_start(ap, arg2);
while (more_args_expected) {
/* Get next argument value. */
this_arg = va_arg(ap, type);
process(this_arg);
}
va_end(ap); /* finished argument processing */
}
| RETURN VALUE |
va_start
has no return value.
| CAUTION |
The results of
va_start
are unpredictable if the argument values are not appropriate.
| EXAMPLE |
| RELATED FUNCTIONS |
| SEE ALSO |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.