Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- // string::substr
- #include <iostream>
- #include <string>
- using namespace std;
- int main ()
- {
- string str="We think in generalities, but we live in details.";
- // quoting Alfred N. Whitehead
- string str2, str3;
- size_t pos;
- str2 = str.substr (12,12); // "generalities"
- pos = str.find("live"); // position OF "live" IN str
- str3 = str.substr (pos); // get from "live" to the end
- cout << str2 << ' ' << str3 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement