Contact: aviboots(AT)netvision.net.il
41,379 questions
53,922 answers
573 users
#include <iostream> int main() { std::string s = "c++ c php java golang nodejs"; std::size_t pos = s.find_last_of("j"); if (pos != std::string::npos) std::cout << pos << " " << s[pos]; else std::cout << "not found"; } /* run: 26 j */
#include <iostream> int main() { std::string s = "c++ c php nodejs java golang nodejs"; std::size_t pos = s.rfind("node"); if (pos != std::string::npos) std::cout << pos << " " << s[pos]; else std::cout << "not found"; } /* run: 29 n */