Hello I have a problem with trimming string in c++. It adds some weird chars at the end of the
string.
string& Napis::subst(char cold, char cnew) {
string * s = new string(data);
replace(s->begin(),s->end(), cold, cnew);
return *s; // takes back string s with changed sign
}
I’ll bet you are calling
substwithcnewset to zero. You are expecting this to delete the characters, but that’s not what it does. It replaces them with zeroes, just as its name suggests.How about: