遇到什么写什么吧,以后再做补充。
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.youkuaiyun.com/koala0923/article/details/9964897