I saw someone use this line to remove white spaces from string stored in a vector, but I fail to understand the reason for using erase and remove this way? The second question: how can I, instead of only removing white spaces, remove anything that is not a 'num' or a '-' ?
this is not the full code, it is only a snippet, will not compile. the vector simply contains raw strings of a text file, the strings were comma delimited, currently the strings could contain any possible char except the comma.
vector <string> vecS;
ifstream vecStream;
while(vecStream.good()) {
vecS.resize(i+1);
getline(vecStream, vecS.at(i), ',');
vector <string> vecS;
vecS.at(i).erase(remove( vecS.at(i).begin(), vecS.at(i).end(), ' '), vecS.at(i).end());
i++
}
EDIT; added more code, hope this is clearer now