This documentation is copyright © 1998-2001 Sandro Sigala <sandro@sigala.it>.
All rights reserved.

Released under the GNU General Public License.

Return to index Return to header Previous symbol Next symbol

va_end

Prototype

#include <stdarg.h>

void va_end(va_list ap);

Description

The va_end macro cleans up the variable arguments data used for scanning the list of arguments before returning the function. This should be called every time a va_start call appears in the same function. In some implementations, the va_end macro does nothing.

Example

View source
#include <stdarg.h>
#include <stdio.h>

/*
 * Print the NULL terminated list of strings.
 * For example:
 *    print_str_list("Hell", "o Wor", "ld", NULL);
 * Prints:
 *    Hello World
 */
void print_str_list(char *s, ...)
{
    va_list ap;

    va_start(ap, s);
    while (s != NULL) {
	printf("%s", s);
	s = va_arg(ap, char *);
    }
    va_end(ap);
    fputc('\n', stdout);
}

References

ISO C 9899:1990 7.8.1.3