#ifndef _tstof
#ifdef _UNICODE double __cdecl _tstof( const wchar_t *ptr )
{
CHAR astring[20];
WideCharToMultiByte( CP_ACP, 0, ptr, -1, astring, 20, NULL, NULL);
return atof(astring);
} #else
#define _tstof atof
#endif
#endif
#ifdef _UNICODE double __cdecl _tstof( const wchar_t *ptr )
{
CHAR astring[20];
WideCharToMultiByte( CP_ACP, 0, ptr, -1, astring, 20, NULL, NULL);
return atof(astring);
} #else
#define _tstof atof
#endif
#endif
解决方案 »
- 123开头的IP是A类还是E类?
- 类的作用域是如何约定的,是不是所有类的作用域都是全局的?
- 关于主线程产生一个子线程的问题
- 三维线段(坐标)---相交判断vc(((((悬赏)
- 哪位大侠给指点一下,为什么我在下载中心下载不了crystal report,总是下载了一部分就提示与服务器的连接被重置?
- 请问关于MSDN里mtgdi例程的问题
- 急:CSOCKET中TCP连接,服务端如何马上知道客户端已断开,为什么onclose()不行?
- 再问一次toolbar如何显示TEXT,
- 这个多线程程序怎么会退出呢?
- windows程序也是一个循环而已,它是怎么做到在没有消息时不占用cpu资源的
- 这样用CString为什么没泄露
- CListCtrl 扩展LVS_EX_GRIDLINES后,网格线的颜色怎么改变?
#ifndef _tstof // 如果没有定义_tstof,才编译以下代码
#ifdef _UNICODE // 分Unicode和非Unicode处理double __cdecl _tstof( const wchar_t *ptr ) // UNICODE程序中使用函数转换为ANSI,再转换为浮点数
{
CHAR astring[20];
WideCharToMultiByte( CP_ACP, 0, ptr, -1, astring, 20, NULL, NULL);// 转换为ANSI字符串
return atof(astring); // 转换为浮点数
}#else
#define _tstof atof // 非UNICODE中直接定义为atof函数
#endif
#endif
总的来说,由于crt的atof只能接收ansi字符串,无法接受unicode字符串,所以当使用unicode时就要进行unicode到ansi的转换才能调用crt的atof进行字符串到浮点的转换。