You are looking for the index where the string changes from one char to another?
Is that what you are looking for?Code:std::string mystring = "ggaagaaag"; size_t index = 0; char last = '\0'; for(std::string::iterator i = mystring.begin(); i < mystring.end(); ++i, ++index){ if (*i != last) std::cout << index; last = *i; } std::cout << index;




Reply With Quote