Here's my problem: I have two files, one containing my main() :
int main()
{
float a;
a = 90;
test(a);
}
and the other one containing a test() function :
float test(float a)
{
printf("a : %f\n", a);
}
So, I compile these files (gcc test.c main.c) and I execute the binary.
But why do the output is
a : 0.0000
and not
a : 90.0000
as expected?
As mentioned in the comments below the actual post, missing to provide the proper signature (forward declaration / prototype) of a function to all the different translation unit using the function will result in a fallback to the function with a signature of
int(obsolete in latest standard)In this case, then, the function call
will be interpreted as a call to a function, returning
intand passing oneintargument which is actually a mismatch (expectedintand actualfloattype), causing the undefined behavior, producing unwated result.