0

how to erase certain characters in a string using a for loop

17th Jan 2020, 4:14 AM
izillid
izillid - avatar
1 Odpowiedź
+ 2
izillid #include <algorithm> str.erase(std::remove(str.begin(), str.end(), 'd'), str.end()); this the common erase but as to a for loop std::string mystrg; mystrg.reserve(str.size()); // algorithms for(size_t i = 0; i < str.size(); ++i) if(str[i] != 'd') mystrg += str[i];
17th Jan 2020, 4:39 AM
BroFar
BroFar - avatar