Rob Hoelz <ho***@wisc.eduwrites:
So these two functions are different:
void foo(void);
and
void foo();
because the first one allows no arguments, but the second does.
This is a misconception. The first declaration declares that
foo() has no parameters. The second declaration does not declare
foo()'s parameters and therefore says nothing about the type or
number of arguments that must be supplied. You can usually
invoke the function whether a prototype is specified or not[*],
but it is safer if you specify a prototype.
[*] Functions with a variable number of arguments are one exception,
functions that have parameters of type that is changed by the
default promotions is another, and I'm not sure that this is an
exhaustive list.
My question is: In the implementation of the second function,
how does one get at those "optional" arguments?
The arguments are not optional. They must be supplied, in the
same way that arguments must be supplied to any other function.
When the function is implemented, the parameters must be
specified, either in prototype form or the now-obsolete K&R form.
--
"For those who want to translate C to Pascal, it may be that a lobotomy
serves your needs better." --M. Ambuhl
"Here are the steps to create a C-to-Turbo-Pascal translator..." --H. Schildt