As Martin York mentioned, exit doesn't perform necesaary clean-up like return does.
It's always better to use return in the place of exit.
Incase if you are not in main, wherever you would like to exit the program, return to main first.
Consider the below example.
With the following program, a file will be created with the content mentioned.
But if return is commented & uncommented exit(0), the compiler doesn't assure you that the file will have the required text.
int main()
{
ofstream os("out.txt");
os << "Hello, Can you see me!\n";
return(0);
//exit(0);
}
Not just this, Having multliple exit points in a program will make debugging harder.
Use exit only when it can be justified.