如何将CString类型转换为其他类型(如long,int,double等,谢谢。

解决方案 »

  1.   

    double atof( const char *string );
    int    atoi( const char *string );
    _int64 _atoi64( const char *string );
    long   atol( const char *string );
      

  2.   

    来晚了啊.
    楼上的说的对.
    在非UNICODED定义下,用上面的.
    在UNICODE定义下,用_wtoi()等,可以参看msdn.
      

  3.   

    在给你补充点 CString --> char* 使用 GetBuffer(0)即可,别忘了调用ReleaseBuffer()CString aaa;int i = atoi(aaa.GetBuffer(0));aaa.ReleaseBuffer();
      

  4.   

    BOOL StrToInt64Ex(
        LPCTSTR pszString,
        DWORD dwFlags,
        LONGLONG * pllRet
        );
    BOOL StrToIntEx(
        LPCTSTR pszString,
        DWORD dwFlags,
        int FAR * piRet
        );
    int StrToInt( 
        LPCTSTR lpSrc 
        );  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with Internet Explorer 4.0 or later). 
      Windows 95/98: Requires Windows 98 (or Windows 95 with Internet Explorer 4.0 or later). 
      Header: Declared in shlwapi.h. 
      Import Library: shlwapi.lib.