#include <iostream>
#include <string>
int main ()
{
std::string str="We think in generalities, but we live in details.";
// (quoting Alfred N. Whitehead)
std::string str2 = str.substr(3,5); // "think"
std::size_t pos = str.find("live"); // position of "live" in str
std::string str3 = str.substr(pos); // get from "live" to the end
std::cout << str2 << ' ' << str3 << '\n';
return 0;
}
Converts parameter c to its lowercase equivalent if c is an uppercase letter and has a lowercase equivalent, as determined by the facet of locale loc. If no such conversion is possible, the value returned is c unchanged.
Erases part of the , reducing its
sequence: Erases the portion of the string value that begins at the character position pos and spans len characters (or until the end of the string, if either the content is too short or if len is .
Notice that the default argument erases all characters in the string (like member function ).
Returns a newly constructed object with its value initialized to a copy of a substring of this object.
The substring is the portion of the object that starts at character position pos and spans len characters (or until the end of the string, whichever comes first).
Position of the first character to be copied as a substring.
If this is equal to the , the function returns an empty string.
If this is greater than the , it throws .
Note: The first character is denoted by a value of 0 (not 1).
Number of characters to include in the substring (if the string is shorter, as many characters as possible are used).
A value of indicates all characters until the end of the string.