delphi将一维数组读入文件 大虾进

2024-12-27 21:58:27
推荐回答(2个)
回答1:

var
ps:array of tpoint;

I: Integer;
alist: TStringList;
begin
SetLength(ps, 6);
ps[0].X :=50;
ps[0].Y :=50;
ps[1].X :=100;
ps[1].Y :=50;
ps[2].X :=125;
ps[2].Y :=75;
ps[3].X :=100;
ps[3].Y :=100;
ps[4].X :=50;
ps[4].Y :=100;
ps[5].X :=25;
ps[5].Y :=75;

alist := TStringList.Create;
try
For I := Low(ps) To High(ps) Do
Begin
alist.Add(Format('%d,%d',[ps[I].X, ps[I].Y ]));
End;
alist.SaveToFile('C:\ps.log');
finally
alist.Clear;
alist.Free;
end;

回答2:

你是要写入文件还是要读?