Antonio T. answered 07/13/19
Tutor
5
(727)
University Of Minnesota TA in C++; 10+ years of CompSci Tutoring
It is more of a personal preference but because you are in main they perform similarly. Furthermore, most compilers accept and compile code even if you don't write return 0; or exit(0); in main!
Note:
- Return statement returns control back to the calling function.
- Exit makes a call to a standard library function which quits the program. Thus, exit is common in situations where you want to terminate the program because there is no need to continue execution.
int main(int argc, char *argv[])
{
if (argc < 2)
{
std::cerr << "please input command to execute" << std::endl;
exit(1);
}
std::cout << "Good Day Sir!" << std::endl;
return 0;
}