#24 Problem with two optional char* arguments

open
nobody
None
5
2012-10-02
2010-10-20
Anonymous
No

When I have two optional command line string arguments, if I don't actually give the first on the command line, its default value gets replaced with the variable name of the second argument. Example:

GetPot cl(argc, argv);
const char outpath = cl("outpath", ".").c_str();
cout << "Outpath is " << outpath << endl;
const char
filepattern = cl("filepattern", "det*.root").c_str();
cout << "Outpath is " << outpath << endl;
cout << "File pattern is " << filepattern << endl;

//...

When I run a program that includes the above, and I don't specify any command line arguments, I get the following output:

Outpath is .
Outpath is filepattern
File pattern is det*.root

Thanks for looking into this!
-Rob.

Discussion

Anonymous
Anonymous

Cancel  Add attachments