This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void chomp (string& str,string victims="\n \t\r") | |
{ | |
string::size_type pos = str.find_last_not_of(victims); | |
if(pos != string::npos) | |
str = str.substr(0, pos+1); | |
else | |
str = ""; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Weed just removes all characters in the "weeds" string from the source string | |
*/ | |
string weed (string& str,string weeds="\n \t\r") | |
{ | |
string rv; | |
for (char c : str) | |
if ((weeds.find(c) == string::npos)) | |
rv.insert(rv.end(),c); | |
return rv; |