Question

program s;
  type info = record
       name, surname: string;
       min, sec: integer;
  end;
  arrays = array[2..50] of info;

  var A: arrays;
begin
  A[1].name := 'name';
end.

What is wrong with that? It gives me range check error and I have no idea what is that.

Was it helpful?

Solution

It gives you an error because you are creating an array from indexes 2 to 50.

So the first element you can access would be 2.

begin
  A[2].name := 'name';
end.

A range check error means that you are trying to access an array in an invalid position (hence, out of range). Pascal, unlike other languages, throws a compilation error if you do this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top