Please,
is there any function to exit the program?
Please,
is there any function to exit the program?
No. You can never exit(0) a program, once you start it, you'll have to power off your PC to stop it.
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
realy?
I mean to exit the program just like the
die in perl.
Of cause I can use Ctrl+C to stop but I
want the program stop itself.
You can use the exit() function, but you shouldnt have a need to use it and it is often deemed bad practice....
To exit you should allow the the code to reach the end of the main() function and let it end naturally
I doubt you can exit a program with ctrl-C either...
It's debatable whether using exit(int i) is bad practice. Sometimes you need to get out of a program fast, and letting it come to an end isn't really an option.
Be sure to delete any allocated memory along with the exit() function though, or stuff will most probably crash, or discard a memory, which might not seem so bad, but if you start and exit the program 100 times, your system resources will start to deplete, especially if your program loads big fat files.