//: C01:CmpIter.cpp // From Thinking in C++, 2nd Edition // Available at http://www.BruceEckel.com // (c) Bruce Eckel 2000 // Copyright notice in Copyright.txt // Find a group of characters in a string #include #include using namespace std; // Case insensitive compare function: int stringCmpi(const string& s1, const string& s2) { // Select the first element of each string: string::const_iterator p1 = s1.begin(), p2 = s2.begin(); // Don't run past the end: while(p1 != s1.end() && p2 != s2.end()) { // Compare upper-cased chars: if(toupper(*p1) != toupper(*p2)) // Report which was lexically greater: return (toupper(*p1)