M
Mike Copeland
How do I remove the last character of a basic::string? Specifically,
I'm using fgets to read lines from a text file, and each ends with the
characters '\10' and '\0'. When I assign the c-string variable to a
basic::string the '\0' is dropped, but the '\10' remains. I want to
erase this character before subsequent processing, but I can't find any
way to do so. I've tried:
string::iterator itr = str.end()-1;
if(*itr == '\10')
str.erase(*itr, 1);
but that doesn't work. Trying to use rbegin() doesn't compile. 8<{{
Please advise. TIA
I'm using fgets to read lines from a text file, and each ends with the
characters '\10' and '\0'. When I assign the c-string variable to a
basic::string the '\0' is dropped, but the '\10' remains. I want to
erase this character before subsequent processing, but I can't find any
way to do so. I've tried:
string::iterator itr = str.end()-1;
if(*itr == '\10')
str.erase(*itr, 1);
but that doesn't work. Trying to use rbegin() doesn't compile. 8<{{
Please advise. TIA