Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. 3
  3. 4
  4. 5
  5. 6
  6. 7
  7. 8
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. // string::substr
  22. #include <iostream>
  23. #include <string>
  24. using namespace std;
  25.  
  26. int main ()
  27. {
  28.   string str="We think in generalities, but we live in details.";
  29.                              // quoting Alfred N. Whitehead
  30.   string str2, str3;
  31.   size_t pos;
  32.  
  33.   str2 = str.substr (12,12); // "generalities"
  34.  
  35.   pos = str.find("live");    // position OF "live" IN str
  36.   str3 = str.substr (pos);   // get from "live" to the end
  37.  
  38.   cout << str2 << ' ' << str3 << endl;
  39.  
  40.   return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement