How to completely end a program if some condition given holds true?

F

faizankhan666

For example if some variable lets say..a is greater than 10 then
program should close....

i.e
"press any key to continue" message appears.
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

For example if some variable lets say..a is greater than 10 then
program should close....

i.e
"press any key to continue" message appears.

#include <cstdlib>


if (a > 10)
exit(0);
 
?

=?ISO-8859-1?Q?Erik_Wikstr=F6m?=

Good hit!
thanx for helping a youngster,

I'd like to point out that it might be better to cast an exception which
is at last caught in main() from where you return instead of using exit,
since this gives you the chance to catch the exception as it propagates
through the call-stack and do some cleaning up (closing files/sockets or
whatever) before re-throwing it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top