0
int main(int argc, char**argv)
{   
if (argc<2)

    goto invokeError;

for (int i=1; i<argc; i++){
    bool found = false;
    string parameter = "";
    for (const auto& test: TestList){  //TestList is the structure Array.
        if (test.name == argv[i]){
            found = true;
            if (i+1 < argc && argv[i+1][0] != '-'){ // get command argument 
                parameter = argv[i+1];
                i++;
            }

            cout << "Running \"" << test.description << "\"" << endl;
            if (!test.classPtr->run(parameter))
                return 0;
            break;
        }
    }
    if (!found)
        goto invokeError; // defined 
}
return 0;
}

Can anyone explain the if condition and loop?

François Andrieux
  • 28,148
  • 6
  • 56
  • 87
mohrafik
  • 26
  • 2
  • That is all basic C++ fundamentals. I think your explanation can be found in an introductory [good C++ book](https://stackoverflow.com/a/388282/4641116). – Eljay Feb 10 '22 at 15:15
  • 1
    *"`goto invokeError; // defined`"*.label is not defined. and `goto` should be avoided when possible. – Jarod42 Feb 10 '22 at 15:19
  • for (const auto& test: TestList){ //TestList is the structure Array. this is my main concern, where can i find this. – mohrafik Feb 10 '22 at 15:25

0 Answers0