C examples for stdarg.h:va_list
data type
<cstdarg>
Type to hold information about variable arguments
#include <stdio.h> #include <stdarg.h> int FindMax (int n, ...){ int val,largest; va_list vl;//from w w w . ja v a 2 s. 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; }