string - Check if the following position of a pointer is null or end of line C++ -
well, have iterator on string in c++
std::string::iterator itb = itc->begin(); and want check if the next position of iterator reaches end of line. i've tried this:
if(*itb ++ != null) also this:
itb++ == itc->end() but i'm confused , need help, since i'm rookie @ pointers in c++.
you want check without modifying it. both of attempts involve modifying itb. if have c++11, that's std::next:
std::next(itb) == itc->end() if don't, make iterator:
std::string::iterator next = itb; ++next; next == itc->end() although, in case know std::string::iterator random access iterator, can do:
itb + 1 == itc->end() (the previous 2 work iterator category)
Comments
Post a Comment