Good afternoon, I am writing an interactive program directed by commands. Some of them have arguments but others do not.
I leave the code of my function main
to give you an idea.
int main(){
char comando[10];
ListaPersonas L = nuevaLista();
mostrarOrdenes();
cout << "orden>" << flush;
cin >> comando;
normalizar(comando);
cout << endl;
while(!sonIguales(comando,"fin")){
ejecutarOpcion(comando, L);
cout << endl;
cout << "orden>" <<flush;
cin >> comando;
normalizar(comando);
cout << endl;
}
return 0;
}
The question is that I need that in the case of being introduced a command that does not require parameters with some extra parameter, this is ignored and only the main command is executed; with my current code in case of writing a parameter of more this is interpreted as a new command entered, which I do not want.
I have been testing with cin.getline()
with different delimiters but without success at the moment.
Greetings, thank you and happy year!