Mail Archives: djgpp/1996/09/05/02:11:01
"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!
Hmm, my thoughts on this has always been that main can be declared
several ways, depending on your needs. If you don't use command line
arguments, you can declare it as taking none, and if you don't need to
return an error code when your program exits, you can declare the
return type void. Thus, for most simple programs (which is usually
what you learn in introductory courses), you'll use..
void main()
However, for a big complex program, you'll generally use this instead:
int main(int argc, char *argv[] )
There isn't any one required way to declare main(). It just depends
on your needs. Of course, almost all sources that teach you
programming always assume simple cases for everything, which doesn't
do anything to prepare you for the 'real stuff' you get into later,
which you have to basically tackle on your own. That's probably the
biggest flaw with courses.
-Jason
+------------------------------------------------------ - - - - -
---------------- Jason Hoffoss, author of DMapEdit
-------- Email: hoffo002 AT gold DOT tc DOT umn DOT edu
--- Homepage: http://www.umn.edu/nlhome/g253/hoffo002
- DMapEdit: http://www.umn.edu/nlhome/g253/hoffo002/dmapedit
- Raw text -