www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/05/02:11:01

Xref: news2.mv.net comp.os.msdos.djgpp:8283
From: hoffo002 AT gold DOT tc DOT umn DOT edu (Jason Hoffoss)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: HELP MEEEEEE!!!!
Date: Wed, 04 Sep 1996 05:27:32 GMT
Organization: University of Minnesota
Lines: 39
Message-ID: <50k7f2$c9f@epx.cis.umn.edu>
References: <01bb9627.474de9c0$146332cc AT robmatthews> <32289180 DOT 543D AT cs DOT com> <01bb97cb$5b601780$4dfb5380 AT maan-m DOT -hamze>
NNTP-Posting-Host: dialup-1-12.gw.umn.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

"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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019