TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: FRANK MASINGILL
from: CLIFF RHODES
date: 1997-05-27 13:19:00
subject: int main()

--> Frank Masingill wrote to Cliff Rhodes <--
 
FM> > Frank, please use int main(void) !!!!
 
FM>But WHY do the books I'm
FM>following not use it?  They are some of the most promient
FM>names like Lafore, etc.  I'm not implying that means they
FM>are right - just asking why you make a point of it?
 
I wish I knew why capable authors used void main(). The only reason I
can think of is that it will compile and they do not think it
necessary to return a completion code to the system.
 
ANSI/ISO C specifies that when running under an Operation System (they
call it a hosted environment), not returning a value results in
undefined behavior. In fact only two forms of main() are specified:
 
int main();
int main(int argc, char *argv[]);
 
C++ is similar in that the above two forms of main() must be 
supported. void main() is not specified, but may be allowed in an 
implementation.
It is a simple thing to return a value from main(), so I cannot
understand why it is not always done. It's not the end of the world if
you don't, but it is a good habit to get into.
 
Cliff Rhodes
cliff.rhodes@juge.com
 
X CMPQwk 1.42 1692 X"None love, but they who wish to love." - Jean Rac
--- Maximus/2 3.01
---------------
* Origin: COMM Port OS/2 juge.com 204.89.247.1 (281) 980-9671 (1:106/2000)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.