Is there another way for me to properly terminate my rock, paper, scissors program other than using exit(1) in my int calculateWinner function? I tried return 0; but it won't work and I'm hesitant to use the exit because I know it is not considered "proper".
my teacher gave us the function prototypes. I can't change them. I'm just looking for a proper way to terminate my program without using the exit(1) in line 78.
As far as possible, a C++ program should avoid calling std::exit().
exit() is C-aware and works well in C programs (for instance it flushes and closes all C streams). The fundamental problem with std::exit() in C++ is that it does not perform clean up of objects with automatic storage duration.
Terminating the program without leaving the current block (e.g., by calling the function std::exit(int)) does not destroy any objects with automatic storage duration. If std::exit is called to end a program during the destruction of an object with static or thread storage duration, the program has undefined behavior.
Because it introduces a hidden control path that bypasses stack unwinding.
Calling std::exit is almost never a good idea. This is because std::exit() does not destroy objects with automatic storage duration. That means unavoidable resource leaks can occur even cross-module or in otherwise exception-safe, RAII-enabled code.
std::exit() is closely related to std::abort(). The functions quick_exit(), abort(), terminate(), exit(), etc., are all there so you can crash your program in the most appropriate manner, but usually you don't want to crash at all. If you have an error that requires that the program ends, consider throwing an exception instead. Even if you don't catch it, at least your destructors will run.
Edit:
Ah, sorry for the duplicate information -- I didn't see JLBorges' post.