The following code works, it prints hello world.
Also, depending on the second value, it either gives segmentation fault or doesn't gives segmentation fault.
Can someone please explain me what is happening internally.

int main = ( cout << "Hello world!\n", 195 );

I am really not sure what is going on here. You are attempting to use a main() function like I've never seen it before. Therefore, this method you are using is more than likely unconventional.

To me, it seems like you are declaring an 'int' type variable called main (which I think is a c++ reserved keyword) and then attempting to initialize the poor int var with a bunch of non-int related gobbledygook.

I am not sure if you are trying to inline the main() function, or attempting to pass in a couple of arguments to the main() function (in which case you could consider using the argc argv[] command-line arguments) or if you are just trying to use a couple of default arguments (which I'm not sure if it is allowed for main()).

Anyway, the rest of the world is coding main() like this:

#include<iostream>
using namespace std;

int main()
{
     cout << "Hello world!\n";
     cin.get();

return 0;
}

Even I code main as the way everyone else does.
I just wanted to know why and how this code works.
I found it as the motto of a top coder contestant.
Even i am totallly confused as to why this code works.

I am lost as well.. without the assignment operator, it would make more sense because it would appear to use a constructor to initialize the main() object, just like one could initialize variable like this:

int x(10), y(20);
This article has been dead for over six months. Start a new discussion instead.