问题描述
如何将C++里的int
类型转换为string
类型
解决方案
使用sstream
库中的stringstream
流
CODE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <sstream> using namespace std;
int () { int a=1000; string str;
stringstream ss; ss<<a; ss>>str;
cout<<a<<endl; cout<<str<<endl;
return 0; }
|
近期评论