How to remove first and last character from std::string, I am already doing the following code.
But this code only removes the last character
m_VirtualHostName = m_VirtualHostName.erase(m_VirtualHostName.size() - 1)
How to remove the first character also?
Well, you could
erase()
the first character too (note thaterase()
modifies the string):But in this case, a simpler way is to take a substring:
Be careful to validate that the string actually has at least two characters in it first...