According to the C standard, there are only two standard, valid ways to portably declare main()
in a hosted implementation:
int main (void) int main (int argc, char *argv[])
There are some allowed equivalents to the above declarations, but note that in particular main()
must return int. As for the actual values that main()
may return, there are only three portably meaningful return values: 0, EXIT_SUCCESS
, and EXIT_FAILURE
. The former two values indicate success; I prefer EXIT_SUCCESS
over 0
for its mnemonic value, but they are equally acceptable. The latter indicates failure. EXIT_SUCCESS
and EXIT_FAILURE
are macros defined in <stdlib.h>
.