void main(void),void main(),main(void),main() or others?
Please answer.Thank you.
--
Posted via CNET Help.com
http://www.help.com/
Nicolas <sct_n...@hotmail.com> wrote in message
news:sflmct...@corp.supernews.com...
> Which of these are ANSI C-compliant?
>
> void main(void),void main(),main(void),main() or others?
>
> Please answer.Thank you.
>
Others.
int main()
int main(void) - This is preferred over int main()
int main(int argc, char **argv)
These are the only forms of main
that comply with the new standard (c99)
Regards
Mike Farnham
> int main()
> int main(void) - This is preferred over int main()
> int main(int argc, char **argv)
>
> These are the only forms of main
> that comply with the new standard (c99)
So is
int main(int argc, char **argv, char** envp)
unix-specific ?
Regis
Michael Farnham wrote:
> int main()
> int main(void) - This is preferred over int main()
> int main(int argc, char **argv)
> These are the only forms of main that comply with the new
> standard (c99)
"Old" standard provided the forms
main()
main(void)
main(int argc,char **argv)
with the return type implied as int. Does the new standard the same, or
this feature is to be considered obsolete? Thank you.
Best regards,
Marco
>
> Regards
> Mike Farnham
Nicolas wrote:
>
> Which of these are ANSI C-compliant?
>
> void main(void),void main(),main(void),main() or others?
[assuming a hosted implementation]
In the current standard (C99), none of the above is legal.
In the old standard (C89/90)
main()
and
main(void)
--
Martin Ambuhl mam...@earthlink.net
What one knows is, in youth, of little moment; they know enough who
know how to learn. - Henry Adams
A thick skin is a gift from God. - Konrad Adenauer
__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com
Regis <re...@info.unicaen.fr> wrote in message
news:38FAD54A...@info.unicaen.fr...
> Michael Farnham wrote:
>
> > int main()
> > int main(void) - This is preferred over int main()
> > int main(int argc, char **argv)
> >
> > These are the only forms of main
> > that comply with the new standard (c99)
>
> So is
> int main(int argc, char **argv, char** envp)
> unix-specific ?
>
I do not know if that prototype of main is used on Unix. I
do know that the only prototypes of main allowed by C99 in
a hosted environment are the three in my original post. If
your prototype is used in a hosted environment then the program
that uses it is non-conforming.
--
Regards
Mike Farnham.
Regis wrote:
>
> Michael Farnham wrote:
>
> > int main()
> > int main(void) - This is preferred over int main()
> > int main(int argc, char **argv)
> >
> > These are the only forms of main
> > that comply with the new standard (c99)
>
> So is
> int main(int argc, char **argv, char** envp)
> unix-specific ?
It is non-standard and even in Unix is deprecated.
Marco Natoni <bl...@nospam.com> wrote in message
news:38FAE2D1...@nospam.com...
>
> "Old" standard provided the forms
>
> main()
> main(void)
> main(int argc,char **argv)
>
> with the return type implied as int. Does the new standard the
same, or
> this feature is to be considered obsolete? Thank you.
>
>
> Best regards,
> Marco
>
The new standard does not allow functions to use implicit return
types. Since main is required to return an int, these three prototypes
do not conform to C99.
--
Regards
Mike Farnham
I think
int main(int argc, char *argv[])
complies as well.
--
Regards,
Jeremy M. Jancsary
janc...@gmx.net
/***************************Quote of the Day************************
* *
* I count him braver who overcomes his desires than him who *
* overcomes his enemies, for the hardest victory is the victory *
* over self. *
* *
* -- Aristotle *
* (Floritegium) *
* *
*******************************************************************/
: I think
: int main(int argc, char *argv[])
: complies as well.
Yes it does. But what about:
int main(int argc, char argv[][])
?
--
/-- Joona Palaste (pal...@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #80 D+ ADA N+++ |
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"You will be given the plague."
- Montgomery Burns
No! Not for any function main or otherwise.
In other functions you could use:
int fred(int argc, char argv[][10])
but this is quite different to
int fred(int argc, char **argv)
or
int fred(int argc, char *argv[])
or even
int fred(int argc, char *argv[10])
Malcolm Kay
>int main(int argc, char argv[][])
^^^^^^^^
It is an illegal form.
>Michael Farnham wrote:
>
>> int main()
>> int main(void) - This is preferred over int main()
>> int main(int argc, char **argv)
>>
>> These are the only forms of main
>> that comply with the new standard (c99)
>
>So is
>int main(int argc, char **argv, char** envp)
>unix-specific ?
Yes. And its deprecated even there because you can do the same thing
portably via the environ global variable.
Mark McIntyre
>
>
> Nicolas <sct_n...@hotmail.com> wrote in message
> news:sflmct...@corp.supernews.com...
> > Which of these are ANSI C-compliant?
> >
> > void main(void),void main(),main(void),main() or others?
> >
> > Please answer.Thank you.
> >
>
> Others.
>
> int main()
> int main(void) - This is preferred over int main()
> int main(int argc, char **argv)
>
> These are the only forms of main
> that comply with the new standard (c99)
>
>
> Regards
> Mike Farnham
He didn't ask about the International Standard, he asked about the
ANSI standard, although he probably did not know the difference. And
at the moment ANSI has not yet approved C99 for procedural reasons.
So at the moment the ANSI standard (9899:1995) allows:
main()
main(void)
int main()
int main(void)
And the variations with argc and argv or equivalents.
According to my last message with ANSI this is expected to change by
the end of April and ANSI will adopt C99. Then the versions without
int will be illegal.
Jack Klein
--
Home: http://jackklein.home.att.net
>
>
> Nicolas wrote:
> >
> > Which of these are ANSI C-compliant?
> >
> > void main(void),void main(),main(void),main() or others?
>
> [assuming a hosted implementation]
> In the current standard (C99), none of the above is legal.
> In the old standard (C89/90)
> main()
> and
> main(void)
<sign>
C99 is the current ISO/IEC standard. It is not the current ANSI
standard, it has not yet been approved.
In ANSI 9899:1995 (current American National Standard),
main()
and
main(int argc, char **argy)
are still legal.
</sign>
But they won't be by next month.