Mail Archives: djgpp/1997/01/27/03:59:42
aho450s AT nic DOT smsu DOT edu (Tony O'Bryan) wrote:
>On Sun, 26 Jan 97 14:59:12 GMT, awnbreel AT panix DOT com (Michael R Weholt)
wrote:
>> Pardon the brief off-topic interlude but why is main() {...}
>>problem? I'm just learning C and all the books and tutorials I'm
>If you're beginning to learn C, then you can pretty much ignore
>messages that tell you not to use main() without the full ANSI
>prototype. In real production code, though, full prototypes of
>everything, including int main(int argc, char *argv[]) are expected and
>help make your code more easily maintained..
main() is stricttly ANSI/ISO conforming because the standard says any
function without an explicit return type is guarenteed to return an int
by default. Hence,
main() == int main()
The problem lies in some compilers not catching certain errors such as
long a,b,c,
main();
ooops! main returns a long and that is NOT legal where as
long a,b,c
int main()
will bring up a complaint about dual type something another. While
this is greek since all that really happened is someone forgot a
semi-colon and used a coma on accident.
>I think the original responder wanted to emphasize the importance of
>making your code adhere to the ANSI standard. I agree that you should
>keep ANSI compliance in mind when you start to write real programs, but
>it's just clutter at the beginning stages of the learning curve.
Believe it or not, the original posters suggestion will actually help
prevent cluttter and has nothiong to do with ANSI conformance.
- Raw text -