A
amonw
Unregistered / Unconfirmed
GUEST, unregistred user!
以下代码可以正常工作:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var buf:array[0..255] of char;
begin
socket.ReceiveBuf(buf,10);
showmessage(buf);
end;
而把buf改成动态数组则会发生访问冲突的错误,代码如下:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var buf:array of char;
begin
setlength(buf,256);
socket.ReceiveBuf(buf,10);
showmessage(pchar(buf));
end;
能告诉我为什么吗?
我怎样才能用动态数组完成类似功能呢?
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var buf:array[0..255] of char;
begin
socket.ReceiveBuf(buf,10);
showmessage(buf);
end;
而把buf改成动态数组则会发生访问冲突的错误,代码如下:
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
var buf:array of char;
begin
setlength(buf,256);
socket.ReceiveBuf(buf,10);
showmessage(pchar(buf));
end;
能告诉我为什么吗?
我怎样才能用动态数组完成类似功能呢?