argc is the nubmer of arguments that the application got when started,*argv[] is an array of C-style string whict contains the arguments
(eg: when launching a program from a file argc[0] is the program path and argc[1] is the file path)

The check is there because argc should not be less than 2.
If it is, then the program regards that as an error, and exits with an error code if 1.
This is why main() is of type int. The return value can be detected by the OS, and typically 0 is OK, non-zero is an error of some sort (what non-zero error code mean is up to the programmer).
If you do not have a return in main, the compiler will automatically add a 'return 0' at then end.

Umz
I don't know if you noticed what caused the problem, but cin.ignore(...) only works if your input stream is completely read and waiting for the user to type something. After using cin >> foo; that is not the case. Try thecoolguy98's method and see if that helps:

The program name is also considered an 'argument' because it is part of the command used to invoke your program. Try running your program from different directories to see how it affects argv[0].
D:\prog\cc\foo\args> a.exe one two three
arguments:
0: a.exe
1: one
2: two
3: three

When you are done playing with the command-line, try double-clicking the executable from Explorer (or from the window manager if you are using Linux or Mac).
[edit] Oh, you'll have to add that pause function and use pause(); before return 0; before you try it from your WM. heh.[/edit]

Hope this helps.

[edit] Added "using namespace std" to the example. (Sorry I forgot that last time.) [/edit]

Hi!
I'm a C++ programming student, and I read through parts of this thread (if that bothers some people... I'm sorry)
I'm writing a program that ends by prompting the user to press any key, circumventing the normal “Press any key to continue…” prompt. So it doesn't have to wait for the newline - any key can terminate it.
Can anyone help me?
Thank you so much!

I presented the example being used on Windows because that is one of the assumptions behind this particular thread, but the code will work identically on Linux, OS X, Plan 9, whatever. (If it doesn't then your compiler is broken.)

(I also fixed an accidental omission above: namespace using std for cout.)

I think I developed three new clots in my brain just by looking at that.
I'm thinking this thread is already long enough, and it's pretty much covered all the possible solutions to this problem. Including the half-assed ones and the ones that just don't work. Maybe it'd be a good idea to lock it, already?