1. Use icode (not code) tag for inline codes.
2. Strictly speaking, bad position value of sttring::find is
const size_t badpos = std::string::npos;
3. Use string output directly, w/o c_str():
cout << windowName;
There is overloaded operator << for std::string.
4. Probably, the memory is corrupted and windowName value is not a valid std::string value. Why? It's the other question, the error context needed...