in K&R C, 2nd Edition, Page 42
Since an argument of a function call is an expression, type conversion also takes place when arguments are passed to functions. In the absence of a function prototype, char and short become int, and float becomes double. This is why we have declared function arguments to be int and double even when the function is called with char and float.
my question is
- confused with the last sentence: if a function func is called with char and float, why don't declare it as
return_type func(char, float);
directly? - One thing I can think of is that it may be more efficient to pass integer and double. But after argumets-passing, it still needed to convert them into char and float, does this really efficient?
/* lower: convert c to lower case; ASCII only */
int lower(int c) // why don't declare c as char?
{
if (c >= 'A' && c <= 'Z')
return c + 'a' - 'A';
else
return c;
}