c++ - how to tell if a string is contained in another string -
this question has answer here:
- check if string contains string in c++ 7 answers
c++ code. example: x: "this #my first program"; y: "#my";
bool function(string x, string y) { //return true if y contained in x return ???; }
you can use std::string::find()
bool function(string x, string y) { return (x.find(y) != std::string::npos); }
Comments
Post a Comment