

The general prototype of the above function :- void _Exit( int exit_argument ) The major difference between this _Exit() and exit(argument) is that the exit(argument) perform cleaning before termination but the _Exit() performs no cleaning before termination of program.Ĭleaning here means closing all the pointers, opened files ,flushes the buffer etc.
#Quit program command code
Sample code using exit() :- void menu(void)Ĭh = getchar() /* read the selection from These above two macros are used in the case of passing the argument to the exit function. This macro indicates unsuccessful execution of the program. This macro means successful execution of the program. Two Macros that are used as argument here are :. The argument is taken to be 0 to indicate normal execution and if some other value is used then that's value is used to show some kind of error. Note that the "returning_value" is returned to the calling process, it means mostly it will return to the operating system. Here the example we will be considering the example of is graphic card is present or not because graphic card is must for running high end games. Now let's look at a pseudo code to identify when we actually use a exit() statement during normal execution of our program. The general prototype of the exit() is :- void exit(int returning_value) This function immediately interrupts and closes the current program in execution. This function forces forcefully termination of the current program and the control is transferred to the Operating system. This function doesn't affect the control flow rather it exits the / closes the current program in execution. It should be noted that this exit() function is not a program control statement used in C programs like break/goto/continue. This function requires the declaration of the C library stdlib.h in which it is defined.Īnd to use this function in C++ we may have to include the C++ library cstdlib. We will, now, go through each of the above methods in detail. Some of the common ways to terminate a program in C are: Starting with the most widely used and most obvious function that is by using the exit() function. In this article, we are going to learn about various methods by which we can terminate a C program which is currently in execution.
