我在对话框中添加了一个Edit控件,将该控件关联了一个CString类型的变量m_edit;
我现在想得到在该控件输入的变量,以便进行计算。
各位大侠我知道通过atoi将其转换成整型,但是不知道如何将其转换成double型呢?
请各位大侠帮帮我,谢谢!!!

解决方案 »

  1.   

    用double atof( const char *string ); 即可
      

  2.   

    强制类型转换atof( const char *string )
      

  3.   

    double dbValue = _tcstod(m_edit, NULL);
      

  4.   

    支持 1 楼,atof
    // crt_atof.c
    //
    // This program shows how numbers stored as 
    // strings can be converted to numeric
    // values using the atof function.#include <stdlib.h>
    #include <stdio.h>int main( void )
    {
        char    *str = NULL;
        double  value = 0;    // An example of the atof function
        // using leading and training spaces.
        str = "  3336402735171707160320 ";
        value = atof( str );
        printf( "Function: atof( \"%s\" ) = %e\n", str, value );    // Another example of the atof function
        // using the 'd' exponential formatting keyword.
        str = "3.1412764583d210";
        value = atof( str );
        printf( "Function: atof( \"%s\" ) = %e\n", str, value );    // An example of the atof function
        // using the 'e' exponential formatting keyword.
        str = "  -2309.12E-15";
        value = atof( str );
        printf( "Function: atof( \"%s\" ) = %e\n", str, value );}
      

  5.   

    要看你编译的工程中,预处理定义的是什么环境啦
    1)_MBCS 
        atof( const char *string );
    2) _UNICODE
       _tcstod(m_edit, NULL);
      

  6.   

    哎,知道有atoi在MSDN上同样地方就有atof呀.