c++ int转换成string类型
大家好,我是一名大二的学生。刚接触c++,不知道哪位高人告诉我在c++中如何将int转换成string,而不是char[]
[解决办法]
- C/C++ code
#include <iostream>#include <string>using namespace std;int main(){ int n = 65535; char t[256]; string s; sprintf(t, "%d", n); s = t; cout << s << endl; return 0;}