C++ string analysis