//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.

Edited 2 Years Ago by Hiroshe

This question has already been answered. Start a new discussion instead.