What is the difference between exit(0) and exit(1) ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between exit(0) and exit(1) ??

What happens when we use exit(2) aur exit function with an argument like 2,3,4

25th Sep 2019, 4:08 PM
CHHAYA GANGWAR
1 Answer
0
They both exit out of the program with an exit code/exit status like returning in the main function. An exit code 0 usually means the program succeeded without errors and 1 usually means an error or failure, anything else are more specific error codes that are specific to your OS. EXIT_SUCCESS and EXIT_FAILURE macros can also be used to indicate success or failure, note that they are not guaranteed to always be 0 and 1 for every platform but they likely will be for most anyways.
25th Sep 2019, 4:24 PM
jtrh
jtrh - avatar