开发者

What is the error in this string loop?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜