Difference Between exit(0) and exit(1)


In this post, we will understand the difference between exit(0) and exit(1).

exit(0)

  • It is portable.

  • It tells about the successful termination or completion of the program.

  • It tells about the termination when the program is executed without any errors.

  • The ‘EXIT_SUCCESS’ macro is used to return code 0.

  • The ‘EXIT_SUCCESS’ can be defined as standard as zero.

Syntax

exit(0);

exit(1)

  • It is not portable.

  • It tells about the abnormal termination of the program.

  • It tells about the termination if the program exited with certain error when the program was being executed.

  • The ‘EXIT_FAILURE’ macro is used to return code 1.

  • It is not restrict by standard to be 1 only.

  • It can be used based on how the system implements it.

Syntax

exit(1);

Updated on: 24-Mar-2021

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements