L
lt_wxy
Unregistered / Unconfirmed
GUEST, unregistred user!
各位高手请先看看下面的代吗。
发送端 :
procedure TForm1.Button1Click(Sender: TObject);
Var
Buf:array OF char;
I:integer;
begin
SetLength(Buf,5);
For I:=1 To 5 do
Buf[I-1]:=PChar(Inttostr(i-1))^;
UdpClient.SendBuffer(Buf,5);
end;
接收端:
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
Buf:Array[0..9] of Char;
I:integer;
begin
Adata.Read(Buf,Adata.Size);
For I:=0 to Adata.Size do
Showmessage(Vartostr(Buf));
end;
发送端的Buf定义为:Buf:Array[0..5] of char 显示正常
为什么Buf定义为:Buf:Array of char 然后动态设置, 显示出来的不是我想要的0,1,2,3,4呢?请指点。谢谢。
发送端 :
procedure TForm1.Button1Click(Sender: TObject);
Var
Buf:array OF char;
I:integer;
begin
SetLength(Buf,5);
For I:=1 To 5 do
Buf[I-1]:=PChar(Inttostr(i-1))^;
UdpClient.SendBuffer(Buf,5);
end;
接收端:
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
Buf:Array[0..9] of Char;
I:integer;
begin
Adata.Read(Buf,Adata.Size);
For I:=0 to Adata.Size do
Showmessage(Vartostr(Buf));
end;
发送端的Buf定义为:Buf:Array[0..5] of char 显示正常
为什么Buf定义为:Buf:Array of char 然后动态设置, 显示出来的不是我想要的0,1,2,3,4呢?请指点。谢谢。