Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>va_start() sets arg_ptr to first optional argument</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 va_start()              Sets arg_ptr to First Optional Argument

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

 void va_start( va_list arg_ptr, prev_param );
 va_list arg_ptr;               Pointer to command-line arguments
 prev_param;                    The name of the required parameter
                                immediately before the first optional
                                argument

    Functions in C can take a variable number of arguments; the
    va_start, va_arg, and va_end macros provide a portable way to read
    the arguments passed to them. Two versions of the macros are
    available: the macros in STDARG.H use the proposed ANSI C standard;
    the macros in VARARGS.H use the UNIX System V definition.

    Usually, a function takes a fixed number of required arguments,
    followed by a variable number of optional arguments. The required
    arguments are declared as normal parameters and can be reached
    through the parameter names. The optional arguments are reached by
    the STDARG.H or VARARGS.H macros. For the ANSI C (STDARG.H) macros:

              * va_start() sets arg_ptr, a pointer of type va_list,
                to the command-line arguments.

              * va_arg() retrieves a value from the location given by
                arg_ptr and increments arg_ptr to point to
                the next argument.

              * After all arguments have been read, va_end() sets
                arg_ptr back to NULL.

    See va_arg() for more information and examples.


See Also: va_arg() va_start() vfprintf() vprintf() vsprintf()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson