Author Topic: STL Case Insensitive Search code  (Read 993 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
STL Case Insensitive Search code
« on: June 14, 2011, 03:28:15 pm »
int StringFindNoCase(const std::string &s1, const std::string &s2, int start = 0)
{
    char *p1 = new char[s1.size() + 1];
    char *p2 = new char[s2.size() + 1];
 
    for(int i = 0; i < s1.size(); i++)
        p1 = toupper(s1);
    p1[s1.size()] = '\0';
    for(int i = 0; i < s2.size(); i++)
        p2 = toupper(s2);
    p2[s2.size()] = '\0';
 
    std::string str1 = p1;
    std::string str2 = p2;
 
    delete p1;
    delete p2;
 
    return str1.find(str2, start);
}

 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1