Kraken Kraken - 1 year ago 89
C Question

Use of exit() function

I want to know how and when can I use the

function like the program in my book:


void main()
int goals;
printf("enter number of goals scored");

goto sos;
exit( );
printf("to err is human");

When I run it, it shows ERROR: call to undefined function exit().

Also, I want to know how I can create an option to close the window in which the program runs? For example, I made a menu-driven program which had several options and one of them was "exit the menu". How can I make this exit the program (i.e. close the window)?

Answer Source

Try using exit(0); instead. The exit function expects an integer parameter. And don't forget to #include <stdlib.h>.