DELPHI里定义数组指针与字符串指针,(菜鸟)问题!(50分)

  • 主题发起人 主题发起人 保龙
  • 开始时间 开始时间

保龙

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样定义数组指针,与字符串指针,可有好的源程序,多谢!
 
數組指針
Arr:Array of Pointer
字符行指針
Pstr^:String;
 
var
ArByte:Array of Byte;
上面定义了一个数组,问题?怎样定义一个(指向ArByte的数组指针)?
 
PStringItem = ^TStringItem;
TStringItem = record
FString: string;
FObject: TObject;
end;

PStringItemList = ^TStringItemList;
//你要的指针;
TStringItemList = array[0..MaxListSize] of TStringItem;
 
var
ArByte:Array of Byte;
PB:PByte;
begin
SetLength(ArByte,100);
PB:=@ArByte[0];
end;
数组指针就是指向数组第一个元素的指针
 
var
a:array[1..11] of char;
pa:Pchar;
i:integer;
begin
for i:=1 to 11do
a:='a';
pa:=@a;
pa^:='2';
Inc(pa);
// 这句等价于 C 的 ptr++;
pa^:='B';
Inc(pa, 2);
//这句等价于 C 的 ptr+=2;
pa^:='C';
pa^:='2';
a[11]:='8';
end;
 
var
ArByte,C:Array of Byte;
begin
SetLength(ArByte,100);
C:=ArByte;//C指向ArByte所指向的单元空间
end;
 
SetLength()是一个怎样的函数?
 
接受答案,并分配积分
 
后退
顶部