C可变参数封装Log函数

Posted cristiano-duan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C可变参数封装Log函数相关的知识,希望对你有一定的参考价值。

#include <stdargs.h>
#include <stdio.h>

void LOGD(const char* fmt, ...)
{
    va_list args;
    va_start(args, fmt);
    char str[256] = {''};
    vsprintf(str, fmt, args);
    va_end(args);
    printf("INFO: %s
", str);
}

以上是关于C可变参数封装Log函数的主要内容,如果未能解决你的问题,请参考以下文章