From Jonathan de Boyne Polla · 1996-04-02 06:32 · #73527 in EMULATE
CN> > JC> CN> void main() > > JC>A minor typo: you misspelled `int' as `void'. >
> Why should it be int?
CN>
Because that's what the language specification says that it should be.
CN>
> The book says void in all examples;
CN>
Then the book (whatever book it is) is wrong.
CN>
> So it returns a value 0 if nothing else is done?
CN>
No. If you drop off the end of a `void main', where the host C++
environment is expecting an `int' return, then the value returned is
undefined in Standard C++.
I've personally encountered implementations where the return value has
been the value of the last expression evaluated in `main' cast to an
`int'. This made for some very strange return codes when the last
statement in `main' was a call to `printf'.
CN>
> In a prog, I take it you would return 1 on an error.
CN>
Actually, that's not entirely correct. By the strict letter of the law
of Standard C, you should return EXIT_SUCCESS to signal a success
status, and EXIT_FAILURE otherwise. You also need to include
<stdlib.h>.
> JdeBP <___
X MegaMail 2.10 #0:
--- Maximus/2 3.01
* Origin: DoNoR/2,Woking UK (44-1483-725167) (2:440/4)