- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library macro - va_end()
Description
The C library macro void va_end(va_list ap) 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.
Declaration
Following is the declaration for va_end() macro.
void va_end(va_list ap)
Parameters
ap − This is the va_list object previously initialized by va_start in the same function.
Return Value
This macro does not return any value.
Example
The following example shows the usage of va_end() macro.
#include <stdarg.h> #include <stdio.h> int mul(int, ...); int main () { printf("15 * 12 = %d\n", mul(2, 15, 12) ); return 0; } int mul(int num_args, ...) { int val = 1; va_list ap; int i; va_start(ap, num_args); for(i = 0; i < num_args; i++) { val *= va_arg(ap, int); } va_end(ap); return val; }
Let us compile and run the above program to produce the following result −
15 * 12 = 180
stdarg_h.htm
Advertisements