- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- cin.tie(0);
- cin.sync_with_stdio(0);
- stringstream ss;
- int a=123;
- float c=123;
- double b=456.789;
- string d="456.789";
- ss<<a;
- ss>>c;
- cout<<"a="<<a<<"型態:"<<typeid(a).name()<<endl;
- cout<<"c="<<c<<"型態:"<<typeid(c).name()<<endl;
- ss.clear();
- ss<<b;
- ss>>d;
- cout<<"b="<<b<<"型態:"<<typeid(b).name()<<endl;
- cout<<"d="<<d<<"型態:"<<typeid(d).name()<<endl;
- return 0;
- }
複製代碼 |