//Hi,can someone explain  what is the difference of declaring the main in C++/C++11
//What is most common may to use or it's metter of personal choice?


int main()
{
 return 0;
}

///////////////////

int _tmain(int argc, _TCHAR* argv[])
{


return 0;

}
///////////////////
int main( int argc, char ** argv ) 
{
return 0;

}

Sure.

int _tmain(int argc, _TCHAR* argv[]) is some Microsoft extention and is not part of any C or C++(11) standard.

int main() or int main(void) are both valid ways to declair main such that the program ignores any command line arguments.

int main(int argc, char *argv[]) and int main(int argc, char **argv) are both valid ways to declair main such that the program does not ignore command line argumments. In this case, argc is the number of arguments and argv is an array of c-strings representing the arguments.

Sometimes you also see int main(int /*argc*/, char** /*argv*/) which is essentially the same as int main(void), except that it satisfies the int/char** prototype (if you happen to be using it for some reason) and doesn't give you any warnings about unused variables. It also might be used to indicate that command line arguments are not accepted yet, but may be in the future.

Here you go.

personally unless I need or want to support command line arguments I just use int main()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.