Re: Re: [Hampshire] C dialects

Top Page

Reply to this message
Author: kevin.bagust
Date:  
To: Hampshire LUG Discussion List
Subject: Re: Re: [Hampshire] C dialects

>
> From: Chris Liddell <cjl@???>
>
> At 13:19 09/07/2007 +0100, you wrote:
>
> ><SNIP>
> >For instance Dev is happy with
> >
> >main()
> >{
> >code
> >}
> >
> >but gcc won't have that, it insists on
> >
> >main (void)
> >{
> >code
> >}
> >
> >A small difference - but most irritating if you're very new to C as I am.


I have just tried the first in gcc on this computer and it works fine. What parameters are you using?

> Both are /wrong/!


Both are valid for C89, but not C99.

> The main() function is:
>
> int main (int argc, char **argv)
>
> or
>
> int main (int argc, char *argv[])
>


or

int main( void )
{
}

which can be written as

int main()
{
}

or in C89 as

main()
{
}

as C89 tells the C compiler, it has to assume int if there is no type declared for a functions return value.

> If you're new to C, it would be best to get into good habits from the start!


Agree.

I would suggest you have a look at the comp.lang.c faq, at http://c-faq.com/.

Kevin Bagust.

-----------------------------------------
Email sent from www.virginmedia.com/email
Virus-checked using McAfee(R) Software and scanned for spam