- #include<iostream>
- #include<cstdlib>
- #include<sstream>
- #include<typeinfo>
- using namespace std;
- int main()
- {
- stringstream ss;
- int a=123;
- double b=456.789;
- float c;
- string d;
- ss<<a;
- ss>>c;
- cout<<c<<endl;
- ss.str("");
- ss.clear();
- ss<<b;
- ss>>d;
- cout<<d<<endl;
- cout<<typeid(a).name()<<endl;
- cout<<typeid(b).name()<<endl;
- cout<<typeid(c).name()<<endl;
- cout<<typeid(d).name()<<endl;
- system("pause");
- return 0;
- }
複製代碼 |