substr() from the 1. to the last character C++

whatfor picture whatfor · Jan 9, 2016 · Viewed 15.9k times · Source

I would like to use substr() function in order to get the chain of characters from the 1. to the last, without 0. Should I do sth like this: string str = xyz.substr(1, xyz.length()); or (xyz.length() - 1) ? And why?

Answer

styvane picture styvane · Jan 9, 2016

You don't need to specify the number of character to include. So as I said in my comment:

string str = xyz.substr(1)

This will return all characters until the end of the string