{s[1]='n' s[2]='e' s[3]='w' s[4]=0;}
{p-->'new'}
var
s:array[1..10] of char;
p:pchar;
begin
{s:='new'+char(0); error}{错误}
p:=@s[1];
{p:=@s; is not correct}
strpcopy(p,'new');
label1.caption:=strpas(p);{new}
label2.caption:=s;{new}
{label3.caption:=intTostr(integer(s[0]));}{不会出现4, 下
超出错误}
end;
例5:下标从0开始的字符数组s,s相当于@s[0]。
{ s[0]='n' s[1]='e' s[2]='w' s[3]=0;}{p-->'new'}
var
s:array[1..10] of char;
p:pchar;
begin
{s:='new'+char(0); error}{错误}
p:=s;
{p:=@s[0] is also correct}
strpcopy(p,'new');
label1.caption:=strpas(p);{new}
label2.caption:=s;{new}
label3.caption:=s[0];{n}
end;
3、下标从0开始和从1开始的字符数组地址的表示方法也有细微不同:
例6:下标从1开始的数组a 与下标从0开始的数组b 的比较。
var
a:array[1..10]of char;
b:array[0..10]of char;
{a:='1..10';}{type mismatch}
{b:='0..10';}{type mismatch}
begin
strpcopy( b, 'from 0 to 10'); {正确 因为b即是@b[0] }
strpcopy(@b[0], 'from 0 to 10'); {正确 与上个表达式
果相同}
strpcopy(@a[1], 'from 1 to 10'); {正确 }
strpcopy( a, 'from 1 to 10'); {类型匹配错误 因为a即是a[0]}
end;