Find if a string contains a character in C++ (boost allowed)

后端 未结 7 757
遇见更好的自我
遇见更好的自我 2020-12-31 05:58

Suppose I have a string and I want to find whether a specific character (like \'|\') is present or not, what is the best and fastest technique to do so? I know string find i

相关标签:
7条回答
  • 2020-12-31 06:54

    You can try this:

       string s1 = "Hello";
       string s2 = "el";
       if(strstr(s1.c_str(),s2.c_str()))
       {
        cout << " S1 Contains S2";
       }
    
    0 讨论(0)
提交回复
热议问题