C ++ syntax conversion small note --- string and an int

And the string conversion int

  • string turn int
. 1 an istringstream is ( " 12 " ); // configured stream input string, the content stream is initialized to "12" string    
2  int I;   
 . 3  is >> I; // the stream is read into a memory integer int of the i  

 

  • int turn string
1 int aa = 30;
2 stringstream ss;
3 ss<<aa; 
4 string s1 = ss.str();
5 cout<<s1<<endl; // 30

 

  • Memory: turn into type int i is the beginning of string is converted into the beginning of the class s

 

Guess you like

Origin www.cnblogs.com/chusiyong/p/11315711.html
Recommended