0
文件读取我读整数的文件,每一个新行,像这样:从帕斯卡
function arrayFromFile(nameFile : string) : pole;
var
userFile : text;
d : data;
i : integer;
p : array;
begin
assign(userFile, nameFile);
reset(userFile);
i:=0;
repeat
inc(i);
readln(userFile, d);
p[i]:=d;
until eof(userFile);
close(userFile);
arrayFromFile:=p;
end;
我遍历这样的:
procedure writeArray(p : array);
var
i : integer;
begin
i:=0;
while p[i+1]<>0 do begin
inc(i);
writeln(p[i]);
end;
end;
后来,当我做然后,如果A更长(有更多的线),它写出一个罚款,但B突然有相同的长度,其余的行是fil以A的整数领导!一个例子是here。
你知道为什么以及如何避免这种行为吗?谢谢。
它解决了这个问题,谢谢。在Pascal中,数组中元素的默认值是什么? – mirgee
没有默认值 –