I want to know how and when can I use the exit() function like the program in my book:
#include
void main()
{
int goals;
Bad programming practice. Using a goto function is a complete no no in C programming.
Also include header file stdlib.h by writing #include for using exit() function. Also remember that exit() function takes an integer argument . Use exit(0) if the program completed successfully and exit(-1) or exit function with any non zero value as the argument if the program has error.