Namespaces
Variants
Actions

Talk:cpp/string/basic string/rfind

From cppreference.com

http://coliru.stacked-crooked.com/view?id=6badefc5100694fe

#include <string>#include <iostream>     int main(){   //If size() is zero, npos is always returned. std::string empty;int n = empty.rfind("", 0);std::cout<<"n = "<< n <<std::endl;//return 0 instead of npos   //If searching for an empty string (str.size(), count, or strlen(s) is zero) //returns pos (the empty string is found immediately) unless pos == npos, //in which case returns size().conststd::string nonempty ="0123456789"; n = nonempty.rfind("", 15);std::cout<<"n = "<< n <<std::endl;//return size() = 10 instead of pos(15)   }

— Preceding unsigned comment added by 91.154.80.197 (talkcontribs)

Fixed. T. Canens (talk) 15:05, 2 February 2018 (PST)
close