开发者

What is the error in this string loop?

开发者 https://www.devze.com 2022-12-09 22:40 出处:网络
for (int开发者_如何学C i = len-2; index>= 0; index --) Without any real context I would venture that int i should be replaced with int index.You are using two variables: i and index, maybe this is
for (int开发者_如何学C i = len-2; index>= 0; index --)


Without any real context I would venture that int i should be replaced with int index.


You are using two variables: i and index, maybe this is causing trouble to you?


Hard to tell from a single line of code, but why are you initializing i, and the checking and decrementing index? Try:

for (int index = len-2; index>= 0; index --)


You are looping through the string backwards? (I suppose that was your intention)

You are also not starting with the very last character in the string, you are starting with the second last (len-2).

0

精彩评论

暂无评论...
验证码 换一张
取 消