我使用Embarcadero公司的C++ Builder的XEEmbarcadero公司無法從「的UnicodeString」轉換爲「無符號字符*」
String command1 = "FREQ ";
String command2 = " Mhz\n";
int index = Form1->ListBox1->ItemIndex;
String full = command1.operator +=(IntToStr((index+2)*10)).operator +=(command2);
TcpClient1->SendBuf((BYTE*)full,13,0);Sleep(30);
,並在最後一行我得到 E2031無法從「的UnicodeString」轉換爲「無符號字符*'
我發送的是我的設備(接收器)格式爲(command,lenght_of_command)的命令。當我在計劃文本發送它像
TcpClient1->SendBuf((BYTE*)"FREQ 330.5 MHz\n",15,0);Sleep(30);
一切正常。非常感謝您的幫助。
工作得很好,感謝 – FRC 2013-04-26 12:54:38
你正在浪費超過900字節,永遠不會被使用。將數組的大小減小到實際需要的最小長度(最大值爲21),或切換到'AnsiString'並使用其'sprint()'方法。 – 2013-05-03 23:06:41