当我运行此程序时
procedure displaydir;
var count:integer;
directoryfile: file of tdir;
directory:array [1..100] of tdir;
begin
assignfile(directoryfile, 'directory.bin');
reset(directoryfile);
count:=0;
repeat
read(directoryfile,directory[count]);
writeln('Name: ',directory[count].name);
writeln('Telephone number: ',directory[count].tel);
writeln('Job title: ',directory[count].jobtitle);
writeln;
writeln;
count:=count+1;
until (directory[count-1].name = 'q');
end;
我收到错误
$ 00000000发生未处理的异常: EAccessViolation:访问冲突 $ 00000000 $ 2A005640 $ B6F83F97
不幸的是我无法在互联网上找到解决方案,非常感谢帮助!
答案 0 :(得分:1)
您已将数组目录声明为1..100,但在首次运行时将count设置为0。目录[0]超出范围。您可能正在尝试写入只读内存。