fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. std::string str="We think in generalities, but we live in details.";
  6. std::string str2 = str.substr (str.length() - 2, 2); // "think"
  7. std::size_t pos = str.find("live"); // position of "live" in str
  8. std::string str3 = str.substr (pos); // get from "live" to the end
  9. std::cout << str2 << ' ' << str3 << '\n';
  10. return 0;
  11. }
Success #stdin #stdout 0s 4572KB
stdin
Standard input is empty
stdout
s. live in details.