@crystall
I think strict ANSI-C code would look like this
#include
#include
int main( void )
{
printf("Hello world!\n");
exit(0);
}
Possibly. However, EXIT_SUCCESS can be used instead of 0, and in general, if there is a define to use, use it instead of fixed value (that way if things would ever change, your code will adapt with just recompile and you don't need to worry about changing all the fixed constants in the code). This is more like generic programming style, not ANSI standard.
I think ansi does state that 0 is "success" for exit(), however. So you're correct here.
Anyway, use of exit() instead of proper failure code path is a bit dull, and forces you to write cleanup stub routines with atexit(), and thus forces you to use global variables. I would advice coders to stay away from exit() if possible, esp if coding for AmigaOS, MorphOS and other compatibles.
The problem is that there is no automatic cleanup for OS resources, just for resources set up by the startup code (stuff provided by the ANSI standard, for example: malloc()d memory, filehandles opened by fopen() etc). So if you would open a intuition window and call exit() to terminate, the window would not get closed (unless if you do it with atexit cleanup stub routine).
Now I got carried away, sorry. :-)