1.1.13.8 buffer and string buffer

stringstream is a convenient way to manipulate strings like an independent I/O device . Sometimes it is very convenient to use stringstream to convert bettween strings and other numerical types. The usage of stringstream are much the same with iostream, so it is not a burden to learn.

You need to build a stringstream from a string, or convert a stringstream back to a string.

stringstream outstr; 
//change number to a text 
outstr<<"salaryvalue"<<123333.00<<endl; 
String str = outstr.str() //change to string 
 
//change text to number 
Istringstream Instr(str); 
While(instr>>number) 
cout<<number<<endl 
////////below is C language///////// 
char sentence []="Yanis41yearsold"; 
char str [20]; 
int i; 
sscanf (sentence,"%s%*s%d", str, &i); 
//* means input will be ignored. So str = Yan, i = 41. 
sprintf(.....);