Secondary packaging of printf() and sprintf()

VA_LIST is a set of macros to solve the problem of variable parameters in C language. It
is located in the header file: #include <stdarg.h>, which is
used to obtain an uncertain number of parameters.

Package printf

void NewPrintf(const char* format, ...)
{
    
    
    va_list args;
 
    va_start(args,format);
    vprintf(format,args); // 用vprintf
    va_end(args);
}

Package sprintf

void NewSprintf(char* buffer, const char* format, ...)
{
    
    
    va_list args;
 
    va_start(args,format);
    vsprintf(buffer,format,args); // 用vsprintf
    va_end(args);
}

Guess you like

Origin blog.csdn.net/xp178171640/article/details/114981940