_z33 wrote:
> I had a wierd doubt today morning. If a function's return type is not
> defined, "C" takes it as returning "int". Now, what does it do when I
> don't specify the arguments of the function. Something like this -
>
> void sampleFunc ()
> {
> /* ... */
> }
>
> Is this equivalent to saying,
>
> void sampleFunc (void)
> {
> /* ... */
> }
The former declares a function taking unspecified arguments, while the
latter declares a function taking no arguments.
You can pass arguments to the former (although it can't use them), but
you will get an error if you try to pass arguments to the latter.
Nowadays, the main use of the former is for declaring a variable or
field which can hold a pointer to arbitrary functions, e.g.
int (*foo)();
declares a variable which can hold a pointer to any function which
returns int, regardless of its argument types.
--
Glynn Clements <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming"
in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html