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


va_start

Initialize the variable-length argument list.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <stdarg.h>
void va_start(va_list ap, ParmN Parm);
Parameters:

Parameters for this facility are:

ap  
va_list  
A variable list  
Parm  
ParmN  
The last named parameter  

Remarks:

The va_start() macro initializes and assigns the argument list to ap. The ParmN parameter is the last named parameter before the ellipsis (...) in the function prototype.

See Also:

"va_arg"

"va_end"

Example of va_start() usage.:
#include <stdarg.h>
#include <string.h>
#include <stdio.h>

void multisum(int *dest, ...);

int main(void)
{
	int all;

	all = 0;
	multisum(&all, 13, 1, 18, 3, 0);
	printf("%d\n", all); 	

	return 0;
}

void multisum(int *dest, ...)
{
	va_list ap;
	int n, sum = 0;
	
	va_start(ap, dest);
	
	while ((n = va_arg(ap, int)) != 0)
		sum += n;	 /* add next argument to dest */
	*dest = sum;
	va_end(ap);	 /* clean things up before leaving */
}

 Output:
3


[ 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