fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main ()
  5. {
  6. std::string str="We think in generalities, but we live in details.";
  7. // (quoting Alfred N. Whitehead)
  8.  
  9. std::string str2 = str.substr (3,5); // "think"
  10.  
  11. std::size_t pos = str.find("live"); // position of "live" in str
  12.  
  13. std::string str3 = str.substr (3); // get from "live" to the end
  14.  
  15. std::cout << str2 << ' ' << str3 << '\n';
  16. std::cout << str3 << std::endl;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5300KB
stdin
Standard input is empty
stdout
think think in generalities, but we live in details.
think in generalities, but we live in details.