----- Original Message -----
From: "peternilsson42" <[email protected]>
To: <[email protected]>
Sent: Tuesday, April 07, 2009 6:33 PM
Subject: [c-prog] Re: C language
> From: "roshni anju" <roshni_a...@...>
> > Is there anyone who can plz tell me What does Main()
> > function return by default in 'C' Language.
A hosted implementation is required to support at least
two forms of main:
int main(void)
int main(int, char **)
Portable return values are 0, EXIT_SUCCESS and EXIT_FAILURE,
the latter two being declared in <stdlib.h>.
In C++ and C99, 'falling off' main, e.g.
int main()
{
/* no return */
}
... will result in a default of 0 being returned. C90
says that if the initial call to main fails to return a
value, then an unspecified termination status will be
returned to the host.
A free standing implementation need not even start via a
function called main.
I don't know. I you sure about exit(0); being portable does the c89 c99
standards say that 0 can always be portable? I always use main() but not in
production or portable code because it's deprecated. I think the only thing
with exit that's guaranteed is EXIT_SUCCESS and EXIT_FAILURE.
Bill
Of course on my implementation 0 is success and 1 failure.