String and each built-in type of interchange method (one usage of Stringstream)

xiaoxiao2021-03-06  110

/ * And C conversion functions are more concealed compared to usage, and it is not intuitive for beginners. * /

#include "iostream" #include "sstream" #include "string" #include "cstdlib", "#include" cstdlib "," #include "cstdlib", "ininclud; int main (void) {/ * The following is a built-in type to String conversion solution * / int tent; char cval; ostringstream out_string; string str; ival = 100; cval = 'w'; out_string << ival << "<< cval; str = out_string.str (); cout << str << end1

/ * The following is a String solution to built-in type conversion * / int itmpe; char ctmpe; str = "100k"; istringstream in_string (str); in_string >> itmpe >> ctmpe; cout << itmpe << "<< CTMPE << Endl; System ("pause"); return 0;}

转载请注明原文地址:https://www.9cbs.com/read-125301.html

New Post(0)