#include <stdio.h> #include <stdarg.h> void MyPrintf(char *format, ...) { va_list ap; va_start(ap, format); vprintf(format, ap); va_end(ap); } void Error(char *format, ...) { va_list ap; va_start(ap, format); fprintf(stdout, "err:"); vprintf(format, ap); va_end(ap); } int main() { MyPrintf("test printf %d %s /n", 1, "hell"); Error("test Error %d %s /n", 1, "hell"); return 0; } 输出结果: test printf 1 hellerr:test Error 1 hellPress any key to continue