From: afn03257 AT freenet3 DOT afn DOT org (Daniel P Hudson) Newsgroups: comp.os.msdos.djgpp Subject: Re: main() {...} (was: using rhide) Date: 27 Jan 1997 03:53:19 GMT Lines: 40 Message-ID: <5ch8rf$qq1@huron.eel.ufl.edu> References: <01bbf2bd$ec4f95c0$590520ce AT d-moran> <01bc0b1f$c48e8ee0$94b15380 AT maan-m DOT -hamze> <5cfriq$1ql AT news1 DOT panix DOT com> <32eb7846 DOT 2272143 AT ursa DOT smsu DOT edu> NNTP-Posting-Host: freenet3.afn.org NNTP-Posting-User: afn03257 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp 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.