CString是MFC當中經常使用的數據類型,通常程序也經常需要將其轉換為unsigned char數組存儲和處理,如何完成這個轉換了?
CString cs1 = "gettruckpos";
byte buf[200];
memcpy(buf,cs1.GetBuffer(cs1.GetLength()),cs1.GetLength()); //將cstring放入byte數組
CString *pPhoneNum =new CString((char*)buf, cs1.GetLength()); //將byte數組轉換成cstring
CString cs2 = *pPhoneNum;