不论是过去写的,还是今天看到的这个:
string cvt2str( int x ){ int d = x; string ans = ""; while( x > 0 ) { d = x%10; ans = char(d+'0')+ans; x /= 10; } return ans;}
转换方法,都不是很好。
我最常用的方法是这样:
#includestd::string int2s(int num){ std::stringstream ss; ss< >re; return re;}