[gameprogrammer] Re: subscript out of range?
- From: Bob Pendleton <bob@xxxxxxxxxxxxx>
- To: Gameprogrammer Mailing List <gameprogrammer@xxxxxxxxxxxxx>
- Date: Mon, 31 Jan 2005 08:36:43 -0600
On Mon, 2005-01-31 at 05:56 -0800, Daniel Greeson wrote:
> Hey everyone I hope everyone is doing well.
>
> I am having a problem I keep getting a subscript out of range error. I
> just added a graphics portion to my source code and this error is popping up
> I was wondering if anyone could give me some information about this error.
> thanks in advance,
>
> ~Draven~
>
Which language are you using? We need to know that to give you specific
information. In general it means that your program is trying to access a
part of a vector or array that does not exist. For example, in C you
might have the declaration:
int iv[10];
Which gives you a vector of 10 integers. The valid subscripts for that
vector are from 0 to 9 inclusive. If I had an expression that included
iv[10] or iv[-1] I would have an out of range subscript error. Now, you
most likely aren't using C because C doesn't normally check for
subscript errors. But, you get the idea.
The most common reason for getting a subscript error is a loop that goes
past the end of a vector. For example:
int i;
int iv[10];
for (i = 0; i <= 10; i++) {
printf("iv[%d] = %d\n", i, iv[i]);
}
Note that the test "i <= 10" will set to to values in the range 0 to 10
and 10 is an invalid subscript of the vector iv.
The error is most likely in your code. But, if you are passing out of
range values to a library function you could be triggering the error in
a library.
Bob Pendleton
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Search presents - Jib Jab's 'Second Term'
>
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
>
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- Follow-Ups:
- [gameprogrammer] Re: subscript out of range?
- From: Daniel Greeson
- References:
- [gameprogrammer] subscript out of range?
- From: Daniel Greeson
Other related posts:
- » [gameprogrammer] subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- » [gameprogrammer] Re: subscript out of range?
- [gameprogrammer] Re: subscript out of range?
- From: Daniel Greeson
- [gameprogrammer] subscript out of range?
- From: Daniel Greeson