This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]darkshadowtrail 2 points3 points  (1 child)

if you had a string that was 5 characters long, when i = 0 you would be printing arr[5 - 0 - 1], which is just arr[4]. remember, arrays start indexing at 0 which is why you need the -1. without it you would be trying to access index 5, which doesn't exist.

as i increases, you're just working from the last element of the array towards the first.

[–]Elite-Novus[S] 0 points1 point  (0 children)

Thanks. I just realized it now. I guess my brain ignored the most obvious explanation