遇到什麼寫什麼吧,以後再做補充。
1、int轉string
string intToString(const int n) //需包含頭文件:#include <sstream>
{
stringstream newstr;
newstr<<n;
return newstr.str();
}
2、WORD轉string
string WORDToString(WORD w)
{
char tmpbuff[16];
sprintf(tmpbuff,"%d",w);
string res=tmpbuff;
return res;
}
注:typedef unsigned short WORD; 所以也可以當做int類型,使用上面的intToString()進行轉換。3、無符號整型(unsigned int)轉string
注:無符號整型還是整型,所以仍然可以用方法1。當然你也可以硬着頭皮寫一個函數,比如這哥們:http://blog.csdn.net/koala0923/article/details/9964897