jacob said:
As specified in the C standard, main returns zero, and it is not
necessary to write a return statement.
Before you start talking nonsense read the standard.
That does not apply to C90. So, for portable use omitting the
return is still a failure, especially since that failure fails to
report any possible i/o errors.
and failure to test the result from printf. From N869:
[#14] The fprintf function returns the number of characters
transmitted, or a negative value if an output or encoding
error occurred.
A correct version could be:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
if (0 > printf("hello\n")) return EXIT_FAILURE;
return 0;
}
If you re read your code you will see that you missed the ELSE
arm of the IF statement. You see?
The only if statement with an else arm was in the above code
snippet, which I wrote as an example for you. And it didn't
contain an else, only implied by bypassing the first return
statement. Ignoring the facts while beating your chest does not
lead to good software. BTW, your code snippet is still fully
quoted above, which should enable you to check my statement. But I
advise calming down first.
Incidentally, in C the else and if keywords are written in lower
case. By convention upper case versions are macros. Failure to
use lower case appropriately can cause unexpected failures in
carelessly written software.