I've been trying to get an if statement to work with two key words. Basically my program will check the first word as the "command" word (like get, set, etc) and the second word as the one to search in a list. They must be both writen together in the same line. I know getline can input several words and cin >> this >> that also does it. But for separate checking I can't be able to figure it out. I was advised substrings, but not sure how to do that.
Example: word inside " " as the command, other as the key to search.
if(input == "kick" ball) {
***does something with the ball
}
if(input == "pick" ball) {
***sets the ball
}
if(input == "throw" paper) {
***gets the paper
}
and so on.
It's probably super simple, I'm just new to c++. It must be this way though, otherwise would probably be better ways.
Would love some help. Thanks ;)
Aucun commentaire:
Enregistrer un commentaire