if a function returns type data bool and we want to exit the program without returning to main(). what's the syntax?
Printable View
if a function returns type data bool and we want to exit the program without returning to main(). what's the syntax?
#include <cstdlib>
exit(EXIT_STATUS);
whats that EXIT_STATUS?
An integer exit status. 0 normally indicates success, anything else is some kind of informational error code. If you are not interested in the value, say exit(1). Be careful.
>>whats that EXIT_STATUS?
A value that I have no way of guessing since you didn't mention what operating system/compiler you use. It's meant to be read as "Insert your favorite exit status here". :-)
Just wanted to say that exiting somewhere IN the program is
a bad thing. If you ever want to go more advanced programming
(win32,OpenGL) you'lle notice that you can't just exit somewhere,
But need to send a signal back to main so it exits from main.
Anyway for console apps it doesn't cause any trouble to exit
anywhere just wanted you to know.
Code:exit(1);
even doing this in a basic windows app will mess things up. Memory leaks are only the tip of the iceberg of side effects.