0
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.

3
  • On which line does it give you a range check? Commented May 16, 2010 at 16:06
  • And by the way, can somebody tell me, how Nick D made so nice edit? Commented May 16, 2010 at 16:14
  • 1
    You can see the edit by clicking on the link "edited X mins ago"; the edit replaced the individual apostrophes you had around each line with simple four-space indentation. stackoverflow.com/posts/2844424/revisions Commented May 16, 2010 at 16:17

1 Answer 1

6

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.