Visual Studio Strange Behavior

I am writing C ++ code in visual studio 2010 as an example for my junior that looks like

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

I did not understand how this program builds and runs without a return statement, if anyone can explain this to me?

+1
source share
1 answer

Without a return statement, the main function uses return 0; by default return 0;

ยง 3.6.1

The return statement basically has the effect of exiting the main function (destroying any objects with automatic storage time) and calling std :: exit with the return value as an argument. If the control reaches the end of main without colliding with the return statement, the effect is that from the execution return 0;

+9
source

Source: https://habr.com/ru/post/948888/


All Articles