PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs223] exit(0) or return(0)
Date: Tuesday, 28 Jan 2020, 07:53:55


    > Message Posted By: Unknown
    >
    > Should our program return with exit(0) or return(0), or neither? Does it
    > matter, and what's the difference?

The return statement returns from the function in which
it appears.  If that function is main(), the program
terminates.

The exit() function causes the program to terminate, no
matter what function it appears in.

Thus in main(), return(0) and exit(0) are equivalent;
but in other functions they are not.

--Stan-
PREV INDEX NEXT