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

void test(const char * format, ...);

int main(void)
{
test("%d_%s", 6, "abc");
return 0;
}

void test(const char * format, ...)
{
char buf[4069];
va_list list;
va_start(list, format);
vsnprintf(buf, 4069, format, list);
va_end(list);
printf("%s\n", buf);
}

 

宏里定义可变参数

https://blog.csdn.net/skyflying2012/article/details/38436711

GNU

#define pr_debug(fmt,arg...) printk(KERN_DEBUG fmt, ##arg)

 
C99
#define dgbmsg(fmt,...)     printf(fmt,__VA_ARGS__)

相关文章:

  • 2021-07-30
  • 2022-02-15
  • 2021-12-09
  • 2022-12-23
  • 2022-02-17
  • 2021-07-31
  • 2021-11-03
  • 2022-12-23
猜你喜欢
  • 2021-12-18
  • 2021-09-29
  • 2021-10-10
  • 2021-07-11
相关资源
相似解决方案