+ 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?

27th Sep 2019, 11:06 PM
DeathPony333
DeathPony333 - avatar
2 odpowiedzi
+ 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 }
28th Sep 2019, 2:57 AM
ΛM!N
ΛM!N - avatar
0
What is a npos, I'm sort of new to c++
28th Sep 2019, 11:37 AM
DeathPony333
DeathPony333 - avatar