Does C/C++ support terminating a program from a subroutine function i.e not main? So far I only found that exit and abort allow a user to terminate current function or process. If I'm not in main function, is there a way to terminate the whole program?
If you are not in main()
and in other function then also you can call exit()
or abort()
it will terminate your whole process.
where exit()
will do required clean up where abort()
will not perform that.
exit(0) or exit(1)
If this is 0
or EXIT_SUCCESS
, it indicates success.
If it is EXIT_FAILURE
, it indicates failure.
ref: See here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With