begin() -> s[0] = 'h';
s[1] = 'e';
s[2] = 'l';
s[3] = 'l';
s[4] = 'o';
s[5] = ?? <- end()
std::distance() makes this irrelevant, but index number 4 is the 5th character, because indexes...
Type: Posts; User: whiteflags
begin() -> s[0] = 'h';
s[1] = 'e';
s[2] = 'l';
s[3] = 'l';
s[4] = 'o';
s[5] = ?? <- end()
std::distance() makes this irrelevant, but index number 4 is the 5th character, because indexes...
A pointer is an iterator type, so &string[pos] is an expression that will get you an iterator, but not necessarily a std::string::iterator. For that instead, write:
string.begin() + pos