main without type and return

Aug 22, 2013 at 7:07pm
My compiler lets me do this:

1
2
3
main()
{
}

Does the C++ standard allow this?
Aug 22, 2013 at 7:12pm
closed account (zb0S216C)
No. The standard states that only the following prototypes are allowed:

1
2
int main( )
int main( int Argc, char **Argv )

Edited: Bad prototype :(

Wazzak
Last edited on Aug 22, 2013 at 7:23pm
Aug 22, 2013 at 7:17pm
Isn't the second parameter supposed to be char* argv[] or char** argv?
Last edited on Aug 22, 2013 at 7:17pm
Aug 22, 2013 at 7:18pm
In old C functions by default have return type int if it was omited. However this is not allowed by more late C/C++ standards. Imolementations may only set different number of arguments.
Last edited on Aug 22, 2013 at 8:13pm
Aug 22, 2013 at 7:33pm
it is not important where u use asterisks as far as i know

they r same:
char* P1; char * P1; char *P1;
Last edited on Aug 22, 2013 at 7:34pm
Aug 22, 2013 at 8:01pm
@Daleth
is there really any difference among the two??
i guess both of 'em are the same...
Aug 22, 2013 at 8:02pm
i totally agree with @Ceset
:D
Aug 22, 2013 at 8:08pm
My post was a response to Framework's previous version of the prototype, which he has already fixed. Before, he accidently wrote int** argv.
Aug 23, 2013 at 12:18pm
@Daleth sorry for misunderstand
Topic archived. No new replies allowed.