Va_start,
Function name, the process of reading a variable parameter is actually in the stack, using pointers, traversing the parameter list in the stack segment, from the low address to the high address one by one to read out the contents of the parameter.
vsprintf ()
The arg parameter is in the array. The percentage of the elements of the array that will be inserted into the main string (%) Symbol. This function is executed step-by. In the first% symbol, insert arg1, insert arg2 at the second% symbol, and so on.
/* Function Name: vsprintf
Return value: Returns the length of the generated string normally (except for \ n), and the error condition returns a negative value usage: int vsprintf (char *string, char *format, va_list param); To write a string in param formatted format format NOTE: This function will have a memory overflow condition, it is recommended to use vsnprintf
with macro Va_arg (), Va_start (), and Va_end (), you can pass a variable number of argument operations to a function. A typical example of a variable number of variables is the function printf (). The type va_list is defined in <stdarg.h>.
The following macro prototypes are as follows: Type Va_arg (va_list argptr, type), void Va_end (va_list argptr), void Va_start (Va_list argptr, last_parm); They are all included in the header file <stdarg.h>. Create a general procedure that can get a variable number of arguments: In a function definition, you must have one or more known parameters before the Variadic table, where the right-most is last_parm. When Va_start () is called, the Last_parm name is used as the second argument. Before any variable-length variables are accessed, the variable-pointer argptr must first be initialized with Va_start (). After initializing the argptr, the call to Va_arg () returns the parameter as the parameter type of the next parameter type. Finally, all parameters are taken out and before the function is returned. Va_end () must be called. This ensures proper recovery of the stack.
Va_start, vsprintf, Va_end