
what's the difference between void main(void) and int main(void)
Quote:
>...What's the difference between void main(void) and int main(void)
>and would I have to have int main(void) return a value?
In the C language, a function does not have to return a value, if the
caller does not extract it.
In the case of main, returning without providing a value leads to an undefined
termination status. So it's better to return something, either
0, EXIT_SUCCESS or EXIT_FAILURE.
The difference between void main(void) and int main(void) is that
they are different function types, and entirely incompatible.
A C program is not required to work right if its main function does
not have one of these two types:
int main(void) { /*...*/ }
int main(int argc, char **argv) { /*...*/ }
The only variation you are permitted is the names of argc and argv,
which don't affect the function's type.
In some programs you may see old-style declarations like
int main() { }
main() { } /* this one has an ``implicit int'' return value */
int main(argc, argv)
int argc;
char **argv;
{ }
Of these, the variants that depend on ``implicit int'' are now considered
incorrect according to the 1999 C standard, which has finally banished
implicit int from the language. Prior to the approval 1999 C standard, the
above forms were still considered correct.
--
#exclude <windows.h>