Command line arguments are passed to your program via the argument count and argument list parameters of main
:
int main(int argument_count, char * argument_list[]);
The first parameter is the number of arguments, including the name of your executable.
The second argument is an array of C-style strings, one for each argument (or word) on the command line. The first item is usually the name of the program.
You can always write a small program to test this out:
#include <iostream>
int main(int arg_count, char * arg_list[])
{
for (unsigned int i = 0; i < arg_count; ++arg_count)
{
std::cout << "Argument " << i << ": " << arg_list[i] << std::endl;
}
return EXIT_SUCCESS;
}
Edit 1:
Your parameters would line up as:
Argument 0: my_executable
Argument 1: --input1
Argument 2: ./file1.csv
Argument 3: --input2
Argument 4: ./file2.csv
//...
If you want to compare these parameters, then yes, you would need to type "input1":
//...
std::string arg1 = arg_list[1];
if (arg1 == "--arg1")
{
//...
}