delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/07/21:02:40

Xref: news2.mv.net comp.os.msdos.djgpp:8391
From: Tom Wheeley <tomw AT tsys DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: HELP MEEEEEE!!!!
Date: Sat, 07 Sep 96 10:38:10 GMT
Organization: City Zen FM
Lines: 55
Message-ID: <842092690snz@tsys.demon.co.uk>
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>
Reply-To: tomw AT tsys DOT demon DOT co DOT uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

On Wednesday, in article <50k7f2$c9f AT epx DOT cis DOT umn DOT edu>
     hoffo002 AT gold DOT tc DOT umn DOT edu "Jason Hoffoss" wrote:

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

That is a bad comparison.  In C, a function (itself, not the code) can
completely ignore the arguments if it wants, as the calling function will
clean up the stack.  Hence declaring with no args will break nothing.
However, whatever a function returns affects the calling function.

This is why C has variable length and type argumeent lists, but *not*
variable type returns.

> Thus, for most simple programs (which is usually
> what you learn in introductory courses), you'll use..
> 
> void main()

And how is this easier than:

main()

 ?

> However, for a big complex program, you'll generally use this instead:
> 
> int main(int argc, char *argv[] )

You mean one that uses arguments.  I have a very small and simple program
which has that.

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

OK, then I want my program to return struct foo, and I want the command line
in one long string.

struct foo main(char *cmdline);

Do you think this will work?

..splitbung                                        http://www.tsys.demon.co.uk
-- 
A great many people think they are thinking when they are merely
rearranging their prejudices.  -- William James
[unknown]

- Raw text -


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