Re: C


Subject: Re: C
From: Daniel E. White (igor@olg.com)
Date: Thu Jan 17 2002 - 06:38:21 MST


Also, by my experience, "main" is sort of a reserved function name.

The full prototype for main is:

int main ( int argc, char *argv[] ) ;

Also, in my experience, you can exclude/ignore the return type and/or the arguments, but do not try to change them. That would be my guess as to why the first example would bomb.

>If you don't specify a return type, C assumes int. And () means
>zero or more parameters of any type. Your main's are not the
>same. If a function's return type is not void, most "modern"
>compilers will yell at you if there's no return. Example #2
>returns some garbage value. I don't know if it's "standard",
>but I write main functions as
>
> #include <stdio.h>
> #include <stdlib.h> /* for exit() */
>
> void main() {
> printf("whatever\n");
> exit(0);
> }
>
>david wright wrote:
>>
>> # include <stdio.h>
>>
>> int main (void)
>> {
>> printf ("whatever\n");
>> return 0;
>> }
>>
>> --------------------- example #2
>>
>> # include <stdio.h>
>>
>> main(){
>> printf ("whatever\n");
>> }

-- 
------------------------------------------------------------------------
                                                               Dan White
------------------------------------------------------------------------
"Sometimes  I  think  the  surest  sign  that  intelligent  life exists
 elsewhere  in the universe is that none of it has tried to contact us."
                                                 Calvin (Bill Watterson)



This archive was generated by hypermail 2a24 : Thu Jan 17 2002 - 06:54:20 MST