Xref: news2.mv.net comp.os.msdos.djgpp:8260 From: korpela AT islay DOT ssl DOT berkeley DOT edu (Eric J. Korpela) Newsgroups: comp.os.msdos.djgpp Subject: Re: HELP MEEEEEE!!!! Date: 4 Sep 1996 17:10:34 GMT Organization: Cal Berkeley-- Space Sciences Lab Lines: 50 Message-ID: <50kd6a$3gm@agate.berkeley.edu> References: <01bb9627.474de9c0$146332cc AT robmatthews> <32289180 DOT 543D AT cs DOT com> <01bb97cb$5b601780$4dfb5380 AT maan-m DOT -hamze> <50k7f2$c9f AT epx DOT cis DOT umn DOT edu> NNTP-Posting-Host: islay.ssl.berkeley.edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article <50k7f2$c9f AT epx DOT cis DOT umn DOT edu>, Jason Hoffoss wrote: >"Maan M. Hamze" wrote: > >>John M. Aldrich wrote in article >><32289180 DOT 543D AT cs DOT com>... > >>> P.S.: I won't go into it now, but 'void main()' is not the right way to >>> define main. If that's what your book recommends, I'd get a better one. >>> >>That is how it is taught in many schools John, in introductory C++ CS >>courses! To the point that it is mentally engrained! "void main()" being taught doesn't make it the right way to define main. If someone taught you that they shouldn't be teaching C. main() MUST return int. The following are acceptable.... main() int main() int main(void) int main(int argc, char **argv) > >Hmm, my thoughts on this has always been that main can be declared >several ways, depending on your needs. Yes, but it MUST always return int. Period. Exclamation point! > Thus, for most simple programs (which is usually >what you learn in introductory courses), you'll use.. > >void main() And you'll do it incorrectly. "void main()" is not legal C. It invokes undefined behavior. There is no guarantee that the program will work properly if main is declared void. >There isn't any one required way to declare main(). It just depends >on your needs. I'll say it again just to be sure you heard me. "main()" must be declared "int"!!!!!!!!!!!! Eric -- Eric Korpela | An object at rest can never be korpela AT ssl DOT berkeley DOT edu | stopped. Click here for more info.