Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Array subscript out of range?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
vindicta




PostPosted: Tue May 06, 2008 4:43 pm   Post subject: Array subscript out of range?

A program I am working on is comparing two strings. When my program gets to this part it always stops and says Array subscript out of range. I can't fix this problem. I think it's because my array or a value in it doesnt exist but when I look through the code it should work fine. What is the actual reason for this error?
Sponsor
Sponsor
Sponsor
sponsor
Zampano




PostPosted: Tue May 06, 2008 4:51 pm   Post subject: Re: Array subscript out of range?

This happened because, as you said, you tried to access an element of the array which did not exist.
What can I say? Check again.
The compiler shows you where the error occurred, so it should be a simple fix. If, by some chance, you were doing some manipulation on an existing value to see which element should be accessed, try to think what value would cause the subscript to leave the range of the array.
isaiahk9




PostPosted: Fri May 09, 2008 3:29 pm   Post subject: RE:Array subscript out of range?

Look for "Trace" in Turing options and you could see where the code goes wrong.
andrew.




PostPosted: Mon May 12, 2008 6:56 pm   Post subject: RE:Array subscript out of range?

Well since you're using strings, I'm pretty sure that each word counts as one individual string. So when you have something like:

code:
get input (i)


put something like:

code:
get input (i) : *


This allows you to enter as many words as possible for each variable.

Good luck on your program.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: