Namespaces
Variants
Views
Actions

Main function

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

 
 
C++ language
General topics
Flow control
Conditional execution statements
Iteration statements (loops)
Jump statements
Functions
Function declaration
Lambda function declaration
inline specifier
Exception specifications (deprecated)
noexcept specifier (C++11)
Exceptions
Namespaces
Types
Specifiers
decltype (C++11)
auto (C++11)
alignas (C++11)
Storage duration specifiers
Initialization
Expressions
Alternative representations
Literals
Boolean - Integer - Floating-point
Character - String - nullptr (C++11)
User-defined (C++11)
Utilities
Attributes (C++11)
Types
typedef declaration
Type alias declaration (C++11)
Casts
Implicit conversions - Explicit conversions
static_cast - dynamic_cast
const_cast - reinterpret_cast
Memory allocation
Classes
Class-specific function properties
Special member functions
Templates
Miscellaneous
 

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;