gcc not compiling

STYMA, ROBERT E (ROBERT) stymar at lucent.com
Mon Oct 31 19:30:44 UTC 2005


void main(...

vs

int main(...

The standard specifies "int main(...".  I agree that
what happens with void main becomes compiler dependent.


>	#include <stdio.h>
>	void main () {
>		printf("\nHello World!\n");
>	}                                                                                                      
>	$ gcc -o foo foo.c
>	foo.c: In function `main':
>	foo.c:2: warning: return type of 'main' is not `int'
>	$ ./foo

In the example, the compiler warning MAY have indicated that
it was overriding the void with in.  Since the original
poster was new coder, best that they learn the approved syntax.

int main(int argc, char *argv[])

The syntax:
int main(int argc, char **argv)
works, but most of the C books I have seen recommend
the *argv[] version.

Bob Styma
	




More information about the fedora-list mailing list