CString 怎么换成 unsigned short我从网络上取下来的字符串分解后,想换成 unsigned short,校时用的

解决方案 »

  1.   

    aoti,然后强行转换成unsigned short不就可以了,前提是不会超过short的范围
      

  2.   

    可是我取出来后,还是无法校时啊?
    SYSTEMTIME ti;      //系统时间对象
    ti.wYearw = (unsigned short)atoi(m_Rec.Mid(0,2)));   //m_Rec为CString类变量
    ti.wMonth =(unsigned short)atoi( m_Rec.Mid(2,2));    //月份ti.wDayOfWeek = 0; //星期日
    ti.wDay = (unsigned short)atoi(m_Rec.Mid(4,2));
    ti.wHour = (unsigned short)atoi(m_Rec.Mid(6,2));
    ti.wMinute = (unsigned short)atoi(m_Rec.Mid(8,2));
    ti.wSecond = (unsigned short)atoi(m_Rec.Mid(10,2));
    ti.wMilliseconds = (unsigned short)0;SetLocalTime(&ti);
      

  3.   

    CString str = "abcdefg";
    char * pStr = str.LockBuffer();
    unsigned short * p = (unsigned short * )pStr;
    ....
    str.ReleaseBuffer();
      

  4.   

    str当中的是单字节的,short可是双字节啊
    这是你需要的吗