i want to show you about stdarg.h in C.
stdarg.h:
- Is a header in the C standard library of the C programming language that allows functions to accept an indefinite number of arguments.
stdarg.h types:
- va_list (type for iterating arguments)
stdarg.h macros:
- va_start (start iterating arguments with a va_list)
- va_arg (retrieve an argument)
- va_end (free a va_list)
- va_copy (copy contents of one va_list to another)
Library macros:
- void va_start(va_list ap, last_arg)
This macro initializes ap variable to be used with the va_arg and va_end macros. The last_arg is the last known fixed argument being passed to the function i.e. the argument before the ellipsis.
- type va_arg(va_list ap, type)
This macro retrieves the next argument in the parameter list of the function with type type.
- void va_end(va_list ap)
This macro allows a function with variable arguments which used the va_start macro to return. If va_end is not called before returning from the function, the result is undefined.
Example:
That's the stdarg.h in C. Hope this will help you. Thanks! :D
nb: Some source that really helps me very much (recommended):
http://www.tutorialspoint.com/c_standard_library/stdarg_h.htm https://en.wikipedia.org/wiki/Stdarg.h
Tidak ada komentar:
Posting Komentar