int turn string
<span style= "FONT-SIZE:18PX;" > #include <cstdio> #include <iostream> #include <sstream>using namespace std; int main () { int int_s = 12345; string S; Declares the string s stringstream stream; Statement Stream stream << int_s; This operator good image ... Put s input stream stream >> s; cout<< "string to numeric result:" <<S<<ENDL; return 0;} </span>
Once converted, you need to first call the. Clear () method if you want to complete the conversion operation again.
Similarly borrowing >> and << can also complete other data types, such as double/string,float/string, and so on, which is not mentioned here.
Ps:
The <sstream> library has only recently been included in the C + + standard. (Do not confuse <sstream> with the <strstream> that was deleted before the standard was released.) As a result, older compilers, such as GCC2.95, do not support it. If you happen to be using such a compiler and want to use <sstream>, you need to update it first.
The Sstream of STL learning Notes