What numbers of arguments are used for main
? What variants of main
definition is possible?
相关问题
- Sorting 3 numbers without branching [closed]
- Multiple sockets for clients to connect to
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
C++ Standard: (Source)
The C++98 standard says in section 3.6.1.2
Commonly there are 3 sets of parameters:
void
int argc, char ** argv
int argc, char ** argv, char ** env
Where
argc
is the number of command lines,argv
are the actual command lines, andenv
are the environment variables.Windows:
For a windows application you have an entry point of WinMain with a different signature instead of main.
OS X: (Source)
Mac OS X and Darwin have a fourth parameter containing arbitrary OS-supplied information, such as the path to the executing binary: