现在的位置: 首页 > 综合 > 正文

ConvertCStringToFloat函数(VS2010测试通过)

2013年09月13日 ⁄ 综合 ⁄ 共 356字 ⁄ 字号 评论关闭

void ConvertCStringToFloat(CString strBuf, float &fTemp )
{
int nLength = strBuf.GetLength();
int nBytes = WideCharToMultiByte(CP_ACP,0,strBuf,nLength,NULL,0,NULL,NULL);
char* pContentBuff = new char[ nBytes + 1];
memset(pContentBuff,0,nBytes+1);
WideCharToMultiByte(CP_OEMCP, 0, strBuf, nLength, pContentBuff, nBytes, NULL, NULL);
pContentBuff[nBytes] = 0;
fTemp = (float)atof(pContentBuff);

}

抱歉!评论已关闭.