On Wed, Jul 18, 2012 at 11:23:33AM +0100, Regan Heath wrote:
> On Tue, 17 Jul 2012 19:39:25 +0100, H. S. Teoh
> <[email protected]> wrote:
[...]
> >This modern C declaration:
> >
> >     int main(int argc, char **argv) {
> >             exit(1);
> >     }
> >
> >is written thus in K&R:
> >
> >     int main(argc, argv)
> >             int argc;
> >             char **argv;
> >     {
> >             exit(1);
> >     }
> 
> Clarification.
> 
> The /definition/ is as you have above, the /declaration/ is not.
> The declaration is what goes in the header file, and in K&R (and
> ANSI C for that matter) looks like:
> 
> int main();
> 
> parameters are not required for the declaration, only the definition.
[...]

You are right.

And also, under K&R syntax, the 'int' can be omitted from before main. I
*think* the entire argc line can be omitted as well (undeclared
variables default to int, IIRC). 'Tis a strange world they used to live
in. :-)


T

-- 
Almost all proofs have bugs, but almost all theorems are true. -- Paul Pedersen

Reply via email to