Are there any problems with defining main as int main (...) {}

I thought a lot about the most honest way of minimally expressing the main function in C (yes, this is trivial and usually not interesting, but I'm interested).

For a long time, to this day, I prefer to define the main as follows:

int main(int argc, char **argv)
{
    return 0;
}

My problem is that I usually never use these arguments, so it makes the arguments explicit, although I don't care about them in the code to write them out.

So I started to do

int main() 
{
    return 0;
}

This is honest, since it does not explicitly state that the function has no arguments, as many do in the definition int main(void){}, and I am satisfied with this.

, main main , "" , , .

int main(...)
{
    return 0;
}

- ...? ... (, , ,...). .

, (... , ), - . , C.

:

  • , - .

  • , / ?

+4
2

, .

, . n1548 6.7.6:

parameter-type-list:
    parameter-list
    parameter-list , ...
parameter-list:
    parameter-declaration
    parameter-list , parameter-declaration

C, ... , . C. , ... , , .

, . , C .

+4

. , .

int main(...) , , !

... , . printf(), . , , :

int printf( const char* format, ... )

main . , , .

main , :

int main( int argc, char **argv )

, , , : int main().

/ main , :

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

OSX:

int main( int argc, char **argv, char **envp, char **apple )

. main printf - . , main(...) .

+1

All Articles