But he's breaking the standard (C89/90), He fails to return a value from main. While exit() is standard most compilers should still flag an error (when compiling in "strict" mode).
You could do the following:
Code:
void MyExit(int code)
{
/* clean up vars here */
exit(code);
}
void foo(void)
{
MyExit(0);
return;
}
int main(void)
{
foo();
return 0; /* never reached, just flag down the warnings */
}
But as MacGyver said, you should generally try and keep your exit()s grouped, as it can make your program hard to read (and workout where it ends). You can avoid it by designing your program well from the start, consider loops with boolean 'flags'.