J
JKop
Let's say that when your program ends (no matter how) that you want a
certain block of code to be executed at the end. Here's the code:
std::cout << "The program will now end.\n";
std::system("PAUSE");
I've looked up "exit", "atexit" and "abort". Up until this point I simply
would've done:
int main()
{
End_of_prog:
std::cout << "The program will now end.\n";
std::system("PAUSE");
}
and used goto statements instead of return statements. But at the moment I'm
thinking of switching to:
#include <iostream>
void DyingWords()
{
std::cout << "The program will now end.\n";
std::system("PAUSE");
}
int main(int argc, char* argv[])
{
atexit(DyingWords);
}
Any thoughts on this?
-JKop
certain block of code to be executed at the end. Here's the code:
std::cout << "The program will now end.\n";
std::system("PAUSE");
I've looked up "exit", "atexit" and "abort". Up until this point I simply
would've done:
int main()
{
End_of_prog:
std::cout << "The program will now end.\n";
std::system("PAUSE");
}
and used goto statements instead of return statements. But at the moment I'm
thinking of switching to:
#include <iostream>
void DyingWords()
{
std::cout << "The program will now end.\n";
std::system("PAUSE");
}
int main(int argc, char* argv[])
{
atexit(DyingWords);
}
Any thoughts on this?
-JKop