I have a variadic function which takes a float parameter. Why doesn\'t it work?
va_arg(arg, float)
As @dasblinkenlight has mentioned, float is promoted to double. It works fine for me:
#include
#include
void foo(int n, ...)
{
va_list vl;
va_start(vl, n);
int c;
double val;
for(c = 0; c < n; c++) {
val = va_arg(vl, double);
printf("%f\n", val);
}
va_end(vl);
}
int main(void)
{
foo(2, 3.3f, 4.4f);
return 0;
}
Output:
3.300000
4.400000