String Class-- C + +-style string class,<string>
Constructor: string (const string& s), string (const char* s)
string (int N,char c);
Operator: <<,>>,=,+,+=,[] does not check out of bounds, the at (int) checks out, and the comparison operator <,<=,>=,>,==,!=
Length: Size (), length (), bool Empty (), resize (NEWSIZE,FILLC)
Convert to C-style: C_str (), data () does not guarantee ' + ', copy (char* to,int n characters, int start = 0) copies the n characters from the start position to the point where to points.
SUBSTRING: substr (int start,int N) returns a string of n characters from start, with the original object still intact
Append: Append (int n,char c) append n characters at the end
Find: Find (char c,int start=0)//from left to right
Find (const char* s, int start=0)//c style
Find (const string& s, int start=0)//c++ style
RFind (...)//parameters are searched from right to left, where you can use String::npos to represent the end npos = 1
Find_first_of (...) Parameters like find, find the first one
Find_fist_of (String S,int start=0), starting from the start position in the string s containing the characters
Find_first_of ("+-*/") indicates that the first operator found in the original string has a return position, no return NPOs found
Find_last_of (...)
Find_fist_not_of (...)
Find_last_not_of (...)
Find return subscript, not found return String::npos
Delete: erase (int start=0,int n = string::npos)
Replace with: replace (int start,int n, new String)
replace (int start,int n,int N2,char C2)
Replace n characters starting with start position with a new string or n2 a C2
Insert: Insert (int pos, new string)
Intsert (int pos,int N,char c)
C + + non-string input: Get (BUF) Easy bounds, fgets (buf,sizeof (BUF), stdin) preserves newline characters at the end, scanf ("%[^\n]", buf) read \ n, reading a row is also easy to cross the line
String Read line: string s; Getline (cin,s);
C + + Learning Note 12--string