C++中将数字转换成string类型

#include
#include
#include
using namespace std;


int main()

{
int i = 54;
string str;


str = to_string(i);//将int转换成string


cout << str << endl;


printf("str = %s\n", str.c_str());


cin.get();


return 0;
}

你可能感兴趣的:(c/c++小例子)