From: loki AT nectar DOT com DOT au-remove (loki) Newsgroups: comp.os.msdos.djgpp Subject: Re: A nice trap! (2) Date: 3 Jun 98 01:22:55 GMT Organization: Nectar Online Services Lines: 43 Message-ID: References: <35715AA9 DOT 4222FD24 AT net4you DOT co DOT at> <35718841 DOT 1129 AT cs DOT com> <357488F9 DOT 6054 AT cs DOT com> NNTP-Posting-Host: 203.18.79.30 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk John M. Aldrich wrote: >The problem is that most people who use don't use an integer return type >for main seem to think that it's standard code because that's the way >they were taught. True, that's a good point :) >1) The return value is used as the program's exit code, and may be used >by any program that invokes yours. I guess it depends; if I knew no other program would ever try to invoke mine I might well declare main() as returning void, mostly so I didn't have to bother writing a return at the bottom. Call me lazy :) >Thus, the shortest legal ANSI C program is as follows: Ah well, to be a little pedantic then we can probably shorten it further. After all, functions that do not explicitly declare a return type are considered to be declared as returning int anyway. Additionally, empty parameters are permissible; IIRC, this means the function may be passed any number and type of arguments, so it is _not_ the same as declaring void (despite what someone else posted in another thread) since that of course explicitly means no parameters. So our slightly shorter program is now: main () { return 0; } Further shortenings are possible (I suppose you could use K&R style braces and chop off one whole line!) but I don't think it's a very productive exercise to go any futher, heh. Of course, you can argue that it's poor style to have a function not explicitly declare its return type, and I would agree. Pretty much ditto about the empty parameter list. -- loki loki (at) nectar.com.au http://puck.nether.net/~loki/ # Dare I disturb the universe? You bet I do!