You have your loop set to $i <= Str.length, which is causing your errror in Str[$i]. Your array index will end at Str.length-1, so when $i = Str.length still goes through the loop Str[$i] will be out of bounds.
EDIT: darn, not fast enough....
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
ahmad mayahi
Greenhorn
Joined: May 10, 2009
Posts: 19
posted
0
Complete code:
W. Joe Smith
Ranch Hand
Joined: Feb 10, 2009
Posts: 710
posted
0
ahmad mayahi wrote:Complete code:
Also, it looks like you are assigning values to the whole array, but are printing just the first value. Not sure if that is what you are planning, just an FYI.
jittu goud
Ranch Hand
Joined: Mar 30, 2007
Posts: 46
posted
0
for (int $i = 0; $i <= Str.length; $i++)
as said by others the array runs from 0 to n-1
you should say $i < Str.length;
.............
i guess this is what you wanted to do.... though $i is variable name $ doesnt make any difference to variable....$i or normal 'i' would make the same output
santhosh.R gowda
Ranch Hand
Joined: Apr 06, 2009
Posts: 296
posted
0
now the code compiles and runs fine. the error is !) we have to type cast to string 2) Array out of bound is run time error bcz you trying to asign the value to the out of index when you put the index as [3] you can assign only up to 0....2 because array index starts from 0 to length -1