+ 1
Is there a way to check a string that was inputted by the user to see if it has a certain character or a certain word and do
Certain commands based on if they typed did type that certain character or words?
2 Respostas
+ 2
You can use str.find(substring)
it will return string::npos if str doesn't contain substring. So you can do this:
if (str.find(substring) != string::npos) {
//Found. you do anything you want here
}
0
What is a npos, I'm sort of new to c++