造冰箱的大熊猫@cnblogs 2024/6/20
1、可变参量
#include <stdio.h> #include <stdarg.h> void debugprint ( const char *format, ... ) { va_list args; va_start(args, format); printf(format, args); va_end(args); } int main()
{ debugprint ( "Hello, %s!\n", "world" ); debugprint ( "The value is: %d, %d, %d\n", 10, 20, 30 ); return 0; }
2、debugprint函数
#include <stdio.h> #include <stdarg.h> void DebugPrintFunc ( const char *format, ... ) { va_list args; va_start(args, format); printf(format, args); va_end(args); } #ifdef _DEBUG #define debugprint (format, args...) DebugPrintFunc(format, args) #else #define debugprint (format, args...) #endif
int main()
{ debugprint ( "Hello, %s!\n", "world" ); debugprint ( "The value is: %d, %d, %d\n", 10, 20, 30 ); return 0; }
标签:va,args,format,参量,debugprint,...,可变,include From: https://www.cnblogs.com/pandabang/p/18259659