Re: strange case of void main

From: Enrico `Trippo' Porreca (trippo_at_lombardiacom.it)
Date: 04/22/04


Date: Thu, 22 Apr 2004 23:44:02 +0200

Ziggy wrote:
> Just for curiosity.
> I know that main function is returning
> an int, but I came cross with the following
> code. (Unnessecary code is snipped) Is there
> any problem with it?
>
> #include <stdlib.h>
> void main(){
> exit(EXIT_SUCCESS);
> }

Yes: main *must* be declared as an int-returning function, even if you
call exit to terminate your program.



Relevant Pages

  • strange case of void main
    ... Just for curiosity. ... an int, but I came cross with the following ... (Unnessecary code is snipped) ...
    (comp.lang.c)
  • Re: strange case of void main
    ... Dan Pop wrote: ... >>an int, but I came cross with the following ... (Unnessecary code is snipped) ...
    (comp.lang.c)
  • [GIT PULL] one kbuild fix
    ... Full patch below. ... Subject: kbuild: soften modpost checks when doing cross builds ... int opt; ...
    (Linux-Kernel)
  • Re: strange case of void main
    ... (Unnessecary code is snipped) ... environment with the current standard. ... void mainisn't of the recommend form: it shall be int mainor int ... termination status of the program returned to the host environnement is ...
    (comp.lang.c)
  • Re: code generation for the ternary operator
    ... int count = lines *3; ... I wondered how clever it is. ... This is just curiosity. ... critical code. ...
    (comp.lang.java.programmer)