Reputation: 11
When I run this procedure
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;
I get the error
An unhandled exception occurred at $00000000: EAccessViolation: Access violation $00000000 $2A005640 $B6F83F97
Unfortunately I couldn't find a solution on the internet, help is much appreciated!
Upvotes: 1
Views: 696
Reputation: 1416
You've declared an array directory as 1..100, but set count to 0 on first run through. directory[ 0] is out of range. You're probably trying to write to read only memory.
Upvotes: 1