Either you was learning a different language or it was a misprint. :) Non of entry point functions has such notation. C++ standard specifies only two of them mentioned in all solutions for your question. I updated this solution with link to ISO C++ standard.

As for 'bracketed phrases'... If you meant char* argv[] then see the complete Solution 1. Well... if you never faced programs with cpmmand-line parameters, then I understand your confusion. Please see this article, maybe it will make it clear for you:
http://en.wikipedia.org/wiki/Command-line_interface

Ok, it explains your confusion. So you may achieve this by launching Command Prompt (cmd.exe) in MS Windows (or launch a console in Linux). Then you should execute your program like "myapp.exe -hello -world". "-hello" and "-world" will be in char *argv[] array.
There is another way to do this. In Visual Studio in your executable project's poperties window go to Debuging section, then write down your "Command arguments" which will appear at the start of you app.

Solution 1

A user can run your program with command-line parameters, for example:

youApplication.exe param1 -i filename.txt /verbose

In this example, the user passes the parameters "param1", "-i", "filename.txt" and "/verbose". That they mean is totally defined by your application.

You can access these parameters via the arguments of main you show. First parameter gives you the number of command line parameters, and the second one, array of strings, gives you the parameter values.

Solution 3

C++ as a language is derived from C, which was originally a console based language. The api "main()" (with or without parameters) is the entry point to your program. If you do not provide parameters, the api is called and your program is not able to see any parameters that may have been passed to the program.

Moving along a few decades now, Microsoft Windows supports ANSI and UNICODE. The API _tmain is a macro that expand to the program entry point main (ANSI) or wmain (UNICODE) according to _UNICODE macro. Starting with VC2005 (?), a program that is UNICODE enabled (ie. _UNICODE defined) will expand _tmain to wmain (not main) and _TCHAR expands to wchar_t.

The Microsoft explanation can be found here[^]. Beware that they have some square brackets in the text that are confusing and can be misinterpreted.

Solution 4

Hey.. I think you are student too. However my teacher says that simply remove this

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

and write a main like this:

int main()

because at that level we are now, we should not consider that.!!
Moreover you write

int main(int a, int b)

it will work but, that is wrong actually this concept is called functions, main is also a function but in main we call the other function and the int a, int b are called parameters.
You should write main as: