Subject: CnPackTip#3:认识静态数组 array[m,n] of x [Print This Page] Author:
skyjacker Time: 2007-3-7 15:37 Subject: CnPackTip#3:认识静态数组 array[m,n] of x
CnPackTip#3:认识静态数组 array[m,n] of x
Written by SkyJacker
http://www.cnpack.org
CnPack IV QQ Group: 130970
2007-3-7
年前 passion 和 Bahamut讨论过。
这里总结一下,有误之处请指出。
var
A: array[0..0] of Char; // 表示一个字符。即 array[0..0] 表示一个此类型的元素
B: array[0..10] of Char; // 下标从0开始的Char数组可以把数组名当作PChar来使用;也可以用字符串直接赋值
C: array[1..10] of Char; // 普通数组
D: array[-1..10] of Byte; // 普通数组
I: Integer;
begin
A[0] := 'A';
B := 'BC';
C[1] := 'D';
D[-1] := 2;
D[0] := Ord('F');
D[1] := Ord('A');
for I := - 1 to 3 do
begin
ShowMessage(IntToStr(D[I]));
end;
ShowMessage(A + '-' + B + '-' + C);
end;
1、关于"Zero-based character arrays" 的 Delhpi Help:
//An array type of the form array[0..x] of Char is called a zero-based character array.
//Zero-based character arrays are used to store null-terminated strings and are compatible with PChar values