下面的代码有什么问题?我们怎样才能使函数 print() 像 printf 一样工作?
#include <stdio.h>
#include<stdarg.h>
void print(char *format,...)
{
va_list args;
va_start(args,format);
printf(format,args);
}
int main() {
print("%d %s",5,"le");
}
最佳答案
如果你需要传递可变参数,那么使用vprintf
相反。
关于c - 模仿printf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10688522/