RE: gcc not compiling

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

 



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
	


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux