- #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 hell
err:test Error 1 hell
Press any key to continue