开发者

Pascal error with array

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?开发者_StackOverflow It gives me range check error and I have no idea what is that.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜