C++ examples for STL:string
Search for a single character in a string using find_first_of.
#include <iostream> #include <string> using namespace std; int main(int argc, char *argv[]) { string myString{ "This is my string!" }; int found = myString.find_first_of("msg"); if (found != string::npos) {/*from ww w. ja va 2 s .c om*/ cout << "is found at position: " << found << endl; } return 0; }