怎么在EDIT中读出char类型的字符串? 
或: 怎么把CString转换成char字符串?
或: 还有其他替代方法?

解决方案 »

  1.   

    1、
    CString str;
    GetDlgItem(IDC_EDIT)->GetWindowText(str);
    之后可以用(LPTSTR)str,就会转换为字符串指针
    2、
    TCHAR str[100];
    GetDlgItem(IDC_EDIT)->GetWindowText(str, 100);
      

  2.   

    to 1.
    编译器提示:
    error C2440: 'type cast' : cannot convert from 'class CString' to 'char *'
            No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    Error executing cl.exe.
      

  3.   

    (LPTSTR)str或(LPCTSTR)str
    而不是(char *)str或(const char *)str