C++任意数值类型转string

#include<iostream>
#include<sstream> 
using namespace std;

template<class T>
string ToString(T value)
{
    stringstream strstream;
    strstream.str("");
    strstream << value;
    return strstream.str();
}

int main()
{
    unsigned long x = 123456;
    string strx = ToString(x);
    printf("x = %s
", strx.c_str());
    return 0;
}
原文地址:https://www.cnblogs.com/liutongqing/p/12486810.html