0
how to erase certain characters in a string using a for loop
2 Respuestas
+ 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];