我想,printf
也会采取va_list
但当我这样做时,printf
并没有做我想做printf
的事:
void Log(int loglevel, char* string, ...)
{
va_list args;
va_start(args, string);
switch (type)
{
case LOGLEVEL_FATAL:
printf("FATAL: ");
break;
case LOGLEVEL_ERROR:
printf("ERROR: ");
break;
case LOGLEVEL_WARNING:
printf("WARNING: ");
break;
case LOGLEVEL_INFO:
printf("INFO: ");
break;
}
printf(string, args);
va_end(args);
}
当我现在打电话时:
Log(LOGLEVEL_INFO, "testvariable = %f", 16.0);
输出是:
INFO: testvariable = 0.000000
但为什么?
我的错误是什么?