//transfer
#include <string> //Note that the distinction is not cstring
//Refer to its identifier in the namespace
using std::string ;
//Basic usage
string input ;
cin >> input ;
<Note> Due to the limitation of the string implementation method, only cin can be used to read in, and scanf cannot be used
---------------------------------------------------------------------------
A series of commonly used constructors
//default constructor
string ( ) ;
//copy constructor, where const means constant
string ( const string &rhs ) ;
/ / Take the string in the object rhs from the position pos to take n characters for initialization
string ( const string &rhs , unsigned int pos , unsigned int n ) ;
string ( const string &name, unsigned int start position, unsigned int initialize length) ;
<Note> The first character inside the string is 0
// Construct an object using an array of strings
string ( const char* s ) ;
---------------------------------------------------------------------------------------
Both string constants and string variables stored using arrays can be used for assignment in strings
string str = " Fight on!" ;
----------------------------------------------------------------------------------------
Various operators contained in string
1) Connect two objects of class string with +
Effect: Concatenate two strings to form a new string
2) Use = for direct string assignment
3) Perform relational operations
4) Size comparison can be done
Compare according to the lexicographical order, the effect is the same as the strcmp function
---------------------------------------------------------------------------
String is actually a defined class, and each definition and use is actually a process of "instantiation";
Using string to perform string related operations is actually "calling a member function of a class" and "calling an overloaded operator"
the process of.
---------------------------------------------------------------------------
The length of the output string:
string名.length( )