stringstream type conversion

stringstream can swallow different types and then spit out different types.

This can realize the conversion of int, string, double and other types

 

1 #include<sstream>
 2  
3  using  namespace std;
 4  
5  int main()
 6  {
 7          int x;
 8          stringstream temp;
 9      temp << x; // swallow the converted type 
10          string s1 = temp .str( ); // spit out the required type 
11  }
 12     

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325058266&siteId=291194637