C Standard Library: 7 Variable Argument Lists: <stdarg.h>
2013-03-21 14:33
429 查看
7 Variable Argument Lists: <stdarg.h>
The header <stdarg.h> provides facilities for stepping through a list of function arguments of
unknown number and type.
Suppose lastarg is the last named parameter of a function f with a variable number of
arguments. Then declare within f a variable of type va_list that will point to each argument
in turn:
va_list ap;
ap must be initialized once with the macro va_start before any unnamed argument is
accessed:
va_start(va_list ap, lastarg);
Thereafter, each execution of the macro va_arg will produce a value that has the type and
value of the next unnamed argument, and will also modify ap so the next use of va_arg returns
the next argument:
type va_arg(va_list ap, type);
The macro
void va_end(va_list ap);
must be called once after the arguments have been processed but before f is exited.
The header <stdarg.h> provides facilities for stepping through a list of function arguments of
unknown number and type.
Suppose lastarg is the last named parameter of a function f with a variable number of
arguments. Then declare within f a variable of type va_list that will point to each argument
in turn:
va_list ap;
ap must be initialized once with the macro va_start before any unnamed argument is
accessed:
va_start(va_list ap, lastarg);
Thereafter, each execution of the macro va_arg will produce a value that has the type and
value of the next unnamed argument, and will also modify ap so the next use of va_arg returns
the next argument:
type va_arg(va_list ap, type);
The macro
void va_end(va_list ap);
must be called once after the arguments have been processed but before f is exited.
相关文章推荐
- stdarg(3) variable argument lists 可变参数列表
- C Standard Library: 11 Implementation-defined Limits: <limits.h> and <float.h>
- standard c library <string.h>
- c++ standard library 学习笔记-auto_ptr<T> 注意事项
- C Standard Library: 6 Diagnostics: <assert.h>
- c++ standard library <numeric> accumulate demo
- C Standard Library: 8 Non-local Jumps: <setjmp.h>
- C Standard Library: 9 Signals: <signal.h>
- Undefined variable: pdo in <b>/var/www/html/gm/application/library/db/dbBase.php
- C Standard Library: 10 Date and Time Functions: <time.h>
- C Standard Library: 3 String Functions: <string.h>
- C Standard Library:4 Mathematical Functions: <math.h>
- C Standard Library: 1 Input and Output: <stdio.h>
- C/C++ standard library -- <cstring>(string.h)
- C Standard Library:5 Utility Functions: <stdlib.h>
- C Standard Library: 2 Character Class Tests: <ctype.h>
- <annotation-driven>里面的<argument-resolvers>参数??
- Eclipse启动Tomcat时发生java.lang.IllegalArgumentException: <session-config> element is limited to 1 occurrence
- ctypes.ArgumentError: argument 1: <class 'TypeError'>: Don't know how to convert parameter 1
- <转>Gdk-WARNING **: locale not supported by C library解决方法