macro
<cstdarg>
va_startvoid va_start (va_list ap, paramN);
Initialize a variable argument list
Initializes ap to retrieve the additional arguments after parameter paramN.A function that invokes va_start, shall also invoke va_end before it returns.
The parameter shall not be a parameter declared with register
storage class, with function or array type, or with a type that is not compatible with the type that results after application of the default argument promotions.
The parameter shall not be of a reference type, or of a type that is not compatible with the type that results when passing an argument for which there is no parameter.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* va_start example */
#include <stdio.h> /* printf */
#include <stdarg.h> /* va_list, va_start, va_arg, va_end */
void PrintFloats (int n, ...)
{
int i;
double val;
printf ("Printing floats:");
va_list vl;
va_start(vl,n);
for (i=0;i<n;i++)
{
val=va_arg(vl,double);
printf (" [%.2f]",val);
}
va_end(vl);
printf ("\n");
}
int main ()
{
PrintFloats (3,3.14159,2.71828,1.41421);
return 0;
}
Output:
Printing floats: [3.14] [2.72] [1.41]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4