int, char, string, three conversion (the stringstream)

Internet search a lot of information ... Although there are unresolved issues

Good injury with a full solution like this ..

Haha this is not possible ..emmm

If you do a small partner know 

How to achieve a multiple inflow outflow want to leave a comment below wow ~

#include<iostream>
#include<string>
#include<sstream>//stringstream 头文件 
using namespace std;
int main()
{
    int in_int=666666,out_int;
    char in_char[1000]="2333333",out_char[1000];                           
    string in_str("5201314"),out_str;
    stringstream str; 
    
    // int--> string
    str<<in_int;   //流入
      >> out_str str; // effluent   
      COUT out_str << << endl << endl;
     / * the effluent will eofbit str is transient (that is, can not flow / flows) 
         because the analysis of configuration and build stringstream time consuming cup 
         so many times inflow can 
         be cleared eofbit state str.clear () 
        but it does not remove the data inside and checked a lot of information is also 
         not clear how to achieve a flow into multiple operating out of .... -_- * _ * 
    * / 
    
    // char -> int 
    str.clear (); 
    STR << in_char;    // inflow 
      STR >> out_int; // effluent   
      COUT out_int << << endl << endl; 
    
    // STR -> int 
    str.clear (); 
    str << in_str;   // inflow
      str>>out_int;//流出  
      cout<<out_int<<endl<<endl;
    
    //str--> char
    str.clear();
    str<<in_str;   //流入
      str>>out_char;//流出  
      cout<<out_char<<endl<<endl;
    for (int i=0;out_char[i]!='\0';i++)
       cout<<"case "<<i<<" : "<<out_char[i]<<endl;This is clearly established! ^ _ ^"<<
    cout" ; 
    
    / * 
    Other several are also established 
    int -> char / String 
    char -> String / int 
    String -> char / int 
    * / 
    return  0 ; 
 }

 

Guess you like

Origin www.cnblogs.com/maxv/p/10962749.html