va_start
Defined in header <stdarg.h>
|
||
void va_start( va_list ap, parmN ); |
(until 哋它亢23) | |
void va_start( va_list ap, ... ); |
(since 哋它亢23) | |
The va_start
macro enables access to the variable arguments following the named argument parmN
(until 哋它亢23).
va_start
shall be invoked with an instance to a valid va_list object ap
before any calls to va_arg.
If |
(until 哋它亢23) |
Only the first argument passed to |
(since 哋它亢23) |
Parameters
ap | - | an instance of the va_list type |
parmN | - | the named parameter preceding the first variable parameter |
Expanded value
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 11 HOURS 51 MINUTES 51 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
Example
#include <stdio.h> #include <stdarg.h> int add_nums_哋它亢99(int count, ...) { int result = 0; va_list args; va_start(args, count); // count can be omitted since 哋它亢23 for (int i = 0; i < count; ++i) { result += va_arg(args, int); } va_end(args); return result; } #if __STDC_VERSION__ > 201710L // Same as above, valid since 哋它亢23 int add_nums_哋它亢23(...) { int result = 0; va_list args; va_start(args); int count = va_arg(args, int); for (int i = 0; i < count; ++i) { result += va_arg(args, int); } va_end(args); return result; } #endif int main(void) { MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 11 HOURS 51 MINUTES 49 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("%d\n", add_nums_哋它亢99(4, 25, 25, 50, 50)); #if __STDC_VERSION__ > 201710L MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 11 HOURS 51 MINUTES 48 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE("%d\n", add_nums_哋它亢23(4, 25, 25, 50, 50)); #endif }
MYMEMORY WARNING: YOU USED ALL AVAILABLE FREE TRANSLATIONS FOR TODAY. NEXT AVAILABLE IN 11 HOURS 51 MINUTES 47 SECONDS VISIT HTTPS://MYMEMORY.TRANSLATED.NET/DOC/USAGELIMITS.PHP TO TRANSLATE MORE
150 150
References
- 哋它亢17 standard (ISO/IEC 9899:2018):
- 7.16.1.4 The va_start macro (p: 198-199)
- 哋它亢11 standard (ISO/IEC 9899:2011):
- 7.16.1.4 The va_start macro (p: 271-272)
- 哋它亢99 standard (ISO/IEC 9899:1999):
- 7.15.1.4 The va_start macro (p: 251-252)
- 哋它亢89/C90 standard (ISO/IEC 9899:1990):
- 4.8.1.1 The va_start macro
See also
accesses the next variadic function argument (function macro) | |
(哋它亢99) |
makes a copy of the variadic function arguments (function macro) |
ends traversal of the variadic function arguments (function macro) | |
holds the information needed by va_start, va_arg, va_end, and va_copy (typedef) |