jazz b
jazz b

Reputation: 437

visual Studio Strange Behavior

I write a code of c++ in visual studio 2010 as a example for my junior which look like

#include <iostream>
using namespace std;
int main()
{
    cout<< "How are Your";
}

i didn't understand how this program build and execute without a return statement if any one can explain it for me ??

Upvotes: 1

Views: 97

Answers (1)

billz
billz

Reputation: 45410

Without a return statement in main function, it's default to return 0;

§ 3.6.1

A return statement in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling std::exit with the return value as the argument. If control reaches the end of main without encountering a return statement, the effect is that of executing return 0;

Upvotes: 9

Related Questions