I've been working on a program recently, and got a bit stuck on a step. When the program is run from the shell, it performs an action when there are no parameters passed. Perhaps someone could assist me, or point me in a proper direction?
int main(int argc, char* argv[])
{
string paramPassed = argv[1];
if(paramPassed == "")
cout << UseDriver();
else if(paramPassed == memMap)
cout << UseMemMap();
else{
if(paramPassed == help)
cout << PrintProgramHelp();
else if(paramPassed == helpMin)
cout << PrintProgramHelp();
else
cout << "Wrong selection. Input --help or -h for more options." << endl;
}
cout << "Press any key to continue." << endl;
cin.get();
return (0);
}
Above code on no input gives me:
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
What can I do? If I don't provide any parameter on program start, it gives me a segmentation fault.
Is there something I'm missing here?
Aucun commentaire:
Enregistrer un commentaire