从edit得到的text是Ctring,我要赋给int型的,请问如何搞??

解决方案 »

  1.   

    CString str;
    int n=atoi(str);
      

  2.   

    楼上说的对,用atoi(CString&)
      

  3.   

    最好是
    CString szInt="8888";
    int n=atoi((LPTSTR)(LPCTSTR)szInt);
      

  4.   

    int m_nBaud;
    Csting dlg.m_sBaud
    m_nBaud=atoi((LPTSTR)(LPCTSTR)dlg.m_sBaud);
    m_nBaud=atoi(dlg.m_sBaud);
    报错:
    error C2664: 'atoi' : cannot convert parameter 1 from 'unsigned short *' to 'const char *'
            Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast