ConvertCStringToFloat函数(VS2010测试通过)

来源:互联网 发布:药品管家软件 编辑:程序博客网 时间:2024/04/30 13:51

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);

}

原创粉丝点击