One. Number --string
(1) Digital to string (new method in c ++ 11)
Example:
int i = 9;
string str = to_string(i);
(2) String to digital
Stoi (); chair (); stoul (); adit (); stoull (), appar ()
Function prototype: int stoi (const string & str, size_t * idx = 0, int base = 10);
Example:
int a;
string str = "1010";
a = stoi (str, 0, 2); // Take 2 numbers from the 0 position
a is 10
two. string-char array
(1) String to char array
char *p;
string str = "hello";
p = str. c_str () ;
(2) char array to string
Direct transfer
char a[10] = "hello";
string str(a);