O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The argv and argc Variables

When creating a program that’s controlled by parameters passed to it from the command line, two variables are of utmost importance. The first of these is called argc, which provides a count of all parameters passed by the command line. The executable name is considered to be a parameter, so argc will always contain a value greater than or equal to 1.

The argv variable contains a two-dimensional array of strings, each one containing a parameter as received from the command line. A parameter is considered to be a value that is flanked by whitespace, although the command-line processor will also allow spaces inside a parameter if the parameter is placed inside quotes.

Because argc is zero-based, you will always find the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required