I have written a simple application that reads a data file, parses the text and then does some processing on that data. The data file is opened in my main() function. Is it good
From main
there's no difference in exit(1)
or return 1
. You use a return/exit value of 0
for success and non 0
for failure.
If your subroutine is a library routine, which is used somewhere else, it should return control to main with some return code or an exception. Otherwise it's your choice, if you exit
or return.
In either case, it's good practice to document what the function does, be it exit
, return
code or exception
.