C examples for stdarg.h:va_start
macro
<cstdarg>
Initialize a variable argument list
void va_start (va_list ap, paramN);
none
#include <stdio.h> #include <stdarg.h> int FindMax (int n, ...){ int val,largest; va_list vl;/* w ww. j av a 2s . c o m*/ va_start(vl,n); largest=va_arg(vl,int); for (int i=1;i<n;i++){ val = va_arg(vl, int); largest=( largest > val ) ? largest : val; } va_end(vl); return largest; } int main (){ int m; m= FindMax (17,7,4,61,84,2,10,72); printf ("The largest value is: %d\n",m); return 0; }