There is a function
void TrimLeft(std::string& str, const char* chars2remove) { if (!str.empty()) { std::string::size_type pos = str.find_first_not_of(chars2remove); if (pos != std::string::npos) str.erase(0,pos); else str.erase( str.begin() , str.end() ); // make empty } } In principle, it is clear that it cuts off the chars2remove characters from the left. If you call her
TrimLeft(s, " "); then everything works fine. But I need to check not only for the space, but also for other non-printing characters, and then I call the function like this:
char *cc = new char[7]; cc[0]= ' '; cc[1] = (char)8; cc[2] = (char)9; cc[3] = (char)10; cc[4] = (char)11; cc[5] = (char)12; cc[6] = (char)13; TrimLeft(s, сс); In this case, when s = "alder" or s = "aspen" (the first letter in the line o), then pos = 1 and the first letter is cut off. I can not understand what's wrong.