我编译运行如下代码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
s:string;
begin
memo1.Lines.Clear;
s:='';
for j:=1 to 100 do begin
for i:=0 to 9 do begin
s:=s+inttostr(i);
end;
s:=s+#0;
end;
i:=memo1.Lines.Add(s);
showmessage(inttostr(length(s))+' '+inttostr(i));
end;
end.
结果是:
showmessage中显示“1100 0”;而memo1中显示“0123456789”。
为什么会这样?