标签:开始 string转换 code i+1 转换 number ng2 bst ==
string string2binstring(string strSrc)
{
if(strSrc.empty())
{
return "";
}
string strTemp = "0x";
string strDest;
//去掉最开始的0x字符
int iNumber = strSrc.find(strTemp);
if(iNumber != NO_FOUND)
{
strSrc = strSrc.substr(2,strSrc.size()-2);
}
for(int i=0;i<strSrc.size();i++)
{
strTemp += strSrc.at(i);
if((i+1)%2 == 0)
{
strDest += strTemp + ",";
strTemp = "0x";
}
}
strDest = strDest.substr(0,strDest.size()-1);
return strDest;
}
标签:开始 string转换 code i+1 转换 number ng2 bst ==
原文地址:https://blog.51cto.com/11998922/2532353