Mail Archives: djgpp/1996/09/04/14:24:38
In article <50k7f2$c9f AT epx DOT cis DOT umn DOT edu>,
Jason Hoffoss <hoffo002 AT gold DOT tc DOT umn DOT edu> wrote:
>"Maan M. Hamze" <mmhamze AT mail DOT utexas DOT edu> wrote:
>
>>John M. Aldrich <fighteer AT cs DOT com> 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.
<a href="http://www.cs.indiana.edu/finger/mofo.ssl.berkeley.edu/korpela/w">
Click here for more info.</a>
- Raw text -