Mail Archives: djgpp/1996/07/17/00:54:56
Reply to message 5546954 from NCHUDNOF AT BINX on 07/16/96 9:30AM
>A while ago, there was a conversation about 'void main()' vs. 'int main()'
>and I wondered if:
>
>void main()
>{
> exit(1);
>}
>
>Is the same as
>
>int main()
>{
> return(1);
>}
You are essentially correct in that those two pieces of code would have
the same effect on the operating system. However, if a program were
to perform recursive calls to main(), the former definition would not work.
Instead of returning, it would terminate the program.
I argue for the correct definition not out of some perverse stubbornness,
but because doing it any other way can get you into trouble if you make
it a habit. And I should know as well as anybody the danger of getting into
bad programming habits! :)
John
- Raw text -