D
dragonhux
Unregistered / Unconfirmed
GUEST, unregistred user!
array[0..79] of Char 与 array[1..80] of Char 区别,有区别吗?
看下面的两个例子:
例子一:
uses SysUtils;
var
A: array[0..79] of Char;
S: String;
begin
S := 'Honk if you know Blaise.';
StrPCopy(A, S);
Canvas.TextOut(10, 10, string(A));
end;
例子二:
uses SysUtils;
var
A: array[1..80] of Char;
S: String;
begin
S := 'Honk if you know Blaise.';
StrPCopy(A, S);
Canvas.TextOut(10, 10, string(A));
end;
改成例子二的方式,就会出现:
[Error] Unit1.pas(33): Incompatible types: 'Array' and 'PAnsiChar'
在array的定义内存实现上难道有区别? :-(
看下面的两个例子:
例子一:
uses SysUtils;
var
A: array[0..79] of Char;
S: String;
begin
S := 'Honk if you know Blaise.';
StrPCopy(A, S);
Canvas.TextOut(10, 10, string(A));
end;
例子二:
uses SysUtils;
var
A: array[1..80] of Char;
S: String;
begin
S := 'Honk if you know Blaise.';
StrPCopy(A, S);
Canvas.TextOut(10, 10, string(A));
end;
改成例子二的方式,就会出现:
[Error] Unit1.pas(33): Incompatible types: 'Array' and 'PAnsiChar'
在array的定义内存实现上难道有区别? :-(