Variadic functions (that is, functions which take a variable number of arguments indicated by the ellipsis (...
) parameter) have weak typing in C. Except in the case of certain special functions like printf
and scanf
, the compiler makes no effort to verify that you're passing the correct types of arguments to them.
In your case, the function is expecting a double
parameter, but you're trying to pass in an int
. The compiler does not do any promotion here from int
to double
, so undefined behavior results. You need to always pass in a double
value here, either as an explicit double
constant value such as 1.0
, or perform the conversion using a typecast.