How to access the last item in string:
string s={"23d;fijaoweilkdc kd"};
s.begin() is pointing to item '2';
s.end() is pointing to item after 'd';
If we need to point to the last item, we can use
string::iterator it=(s.end()-1); OR
string::iterator it=s.end(); --it;
No comments:
Post a Comment