Guardian C Library Calls Reference Manual
Reference to Library Calls
Guardian TNS C Library Calls Reference Manual—128833 3-231
va_end
Example
The function defined in this example uses va_start, va_arg, and va_end to compute the
average of a variable number of double values:
#include <stdargh>
/* ... */
double dbl_average(int count, ...)
{
va_list ap;
double div,avg;
if (count<=0)
return 0.0;
va_start(ap, count);
if (count==1)
{
avg=va_arg(ap, double);
va_end(ap);
return avg;
}
div=count;
for (avg=0.0;count>0;count--)
avg+=va_arg(ap, double);
va_end(ap);
return (avg/div);
}
va_end
The va_end macro enables a normal return from a function that uses a variable number
of arguments.
ap
is a variable of type va_list that has been initialized by a previous invocation of the
va_start macro.
Return Value
none.
Example
The example for the va_arg macro demonstrates the usage of va_end.
#include <stdargh>
void va_end(va_list ap);