
Patrick B. answered 07/23/19
Math and computer tutor/teacher
these are optional command line arguments...
int argc: the number of arguments (tokens) specified on the command line (and passed to main)
char * argv[] : the array of string tokens passed as arguments on the command line to the main
However, argv[0] contains the name of the executable file.
For example...
The program name is myprog.cpp. It is compiled and linked to myprog.exe. Then, at
the command prompt, to run the program...
prompt :> myprog.exe one two three
Command line argument #1 is myprog.exe <--- actually it is the entire full pathname of the program
Command line argument #2 is one
Command line argument #3 is two
Command line argument #4 is three
Here is the source code
============================================
using namespace std;
#include <iostream>
int main(int argc, char * argv[])
{
for (int iLoop=0; iLoop<argc; iLoop++)
{
std::cout << " command line argument # " << (iLoop+1) << " is >" << argv[iLoop] << "<" << endl;
}
}