0

When do we use 'return 1' instead of 'return 0' ?

So far I have observed we write 'return 0' . I have never seen someone writing 'return 1'.Difference between them is not clear to me.

26th Jun 2017, 1:13 PM
Ashwani Devrari
Ashwani Devrari - avatar
2 Answers
+ 2
return 0 in main is EXIT_SUCCESS. Any other number indicates to the parent process that its child process did not do what it was supposed to do. Ex, you may add a return 1 in main if a file was not found, so that way when you launch your process as a child you can know whether or not it worked.
26th Jun 2017, 1:38 PM
aklex
aklex - avatar
0
To manually control program crashes but its better to use try.. Catch block
26th Jun 2017, 1:18 PM
Nura Programmer
Nura Programmer - avatar