| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | int main(void) |
Sunday November 20 1994 21:47, Rafael Solomon wrote to Grant Beattie:
ac>> int main(void)
(You wrote to Grant but quoted my text.)
> I have only started programming in C so I haven't used that can you
> tell me the advantages of that compared to "void main()"
If you specify a return type of "void" (return void [nothing]
when your program exits), there is no guarantee your program will return an
error code of 0.
If you specify a return type of "int" (return an integer when
your program exits) you may return an errorcode (or errorlevel) back to the
calling program, eg.
/* Target: MS-DOS, OS/2, others */
#include
int main(void)
{
puts("Returning to calling program, returning with error code of
5...");
return(5);
}
By placing "void" in the argument list for the main() function
you're telling the compiler that main() takes no arguments.
int main()
...
and
int main(void)
...
may be interpreted differently by some compilers, apparently.
ZeeYa...
Andrew.
---
* Origin: Blizzard of Ozz, Long Beach City, Melbourne, OZ (3:633/267.1)SEEN-BY: 50/99 54/54 620/243 623/630 624/50 632/348 386 998 633/104 251 252 SEEN-BY: 633/253 259 260 262 267 269 371 373 634/384 635/301 502 503 541 544 SEEN-BY: 636/100 639/100 711/401 409 410 430 510 807 808 809 932 934 942 SEEN-BY: 712/623 713/888 714/906 800/1 @PATH: 633/267 252 371 635/503 50/99 54/54 711/808 809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
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™.