Namespaces
Variants
Views
Actions

Main function

From cppreference.com
< cpp‎ | language
Revision as of 14:56, 13 January 2013 by 87.153.239.249 (Talk)

 
 
C++ language
General topics
Flow control
Conditional execution statements
Iteration statements
Jump statements
Functions
function declaration
lambda function declaration
function template
inline specifier
exception specifications (deprecated)
noexcept specifier (C++11)
Exceptions
Namespaces
Types
decltype specifier (C++11)
Specifiers
cv specifiers
storage duration specifiers
constexpr specifier (C++11)
auto specifier (C++11)
alignas specifier (C++11)
Initialization
Literals
Expressions
alternative representations
Utilities
Types
typedef declaration
type alias declaration (C++11)
attributes (C++11)
Casts
implicit conversions
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-style and functional cast
Memory allocation
Classes
Class-specific function properties
Special member functions
Templates
class template
function template
template specialization
parameter packs (C++11)
Miscellaneous
Inline assembly
 

A program shall contain a global function called main, which is the designated start of the program.

int main () { Template:sparam } (1)
int main (int Template:sparam, char *Template:sparam[]) { Template:sparam } (2)

Explanation

argc - the number of arguments passed to the program from the environment in which the program is run.
argv - These arguments are passed as null-terminated multibyte strings in argv[0] through argv[argc-1], the value of argv[argc] is 0.
body - the body of the main function. As a special case, if control reaches the end of main without encountering a return statement, the effect is that of executing return 0;