采用像 printf 这样的函数,它接受可变数量的参数,我想做的是将这些可变数量的函数传递给子函数而不改变它们的顺序。这方面的一个例子是将 printf 函数别名为一个名为 console ...
#include <stdio.h>
void console(const char *_sFormat, ...);
int main () {
console("Hello World!");
return 0;
}
void console(const char *_sFormat, ...) {
printf("[APP] %s\n", _sFormat);
}
例如,如果我这样做了console("Hello %s", sName)
,我也希望将名称传递给 printf 函数,但它必须能够像 printf 已经接受的那样继续接受可变数量的参数。