In this method I need to return ("\r") if in my file if a line contains strip tailing. Is this the correct way? cause i am finding how to remove strip tailing but am not quite sure if that how i should return "\r"
std::ifstream myfile;
std::string s;
if (myfile.is_open()) {
while (std::getline(myfile,s)) {
std::string& ltrim(std::string &s)
{
auto it = std::find_if(s.begin(), s.end(),
[](char c) {
return !std::isspace<char>(c, std::locale::classic());
});
s.erase(s.begin(), it);
return s;
}
std::string& rtrim(std::string &s)
{
auto it = std::find_if(s.rbegin(), s.rend(),
[](char c) {
return !std::isspace<char>(c, std::locale::classic());
});
s.erase(it.base(), s.end());
return s;
}
std::string& trim(std::string &s) {
return ltrim(rtrim(s));
}