[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: gcc not compiling



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
	


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]