is there any way to have a program terminate at the end, like the system("pause") command pauses it, so would there be a system command to end the program?
What would be the point?
If you want to terminate the program, call exit(0) (or with another error code instead of 0).
The program automatically terminates at the end anyway (i.e. when main returns).
Yes the command is return 0; if the program is successful.
I may be reading a bit too much into your question but you seem to be trying to write a condition for the user to quit the program before it finishes? Or give them an option to exit an infinite loop?
int main()
{
//code code code and hey look at that more code!
//...
//...
cin<<done;
if(done == 1)
{
return 0;
}
//More code if need be
//...
//...
return 0;
}
As I understand it, the OP is looking for a function to terminate the program. The exit() function in <cstdlib> does that. However, the best practice is to properly terminate by returning from main().