- #include<iostream>
- #include<cstdlib>
- #include<sstream>
- #include<typeinfo>
- using namespace std;
- int main()
- {
- stringstream ss;
- int a=1234567890;
- double b=0.1234455678;
- float c;
- string d;
- ss<<a;
- ss>>c;
- cout<<c<<endl;
- 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;
- }
複製代碼 |