String function problem

This is a discussion on String function problem within the C Programming forums, part of the General Programming Boards category; Hi, I have made a function that takes a pointer to a string, and the strings length and cleans out ...

A common mistake. For loops like that which use an variable to index all the elements of a string, it's probably easier to use a for loop insead of a while. In case you don't know much about for loops, here's a syntax reference. If you already know about for loops, ignore the rest of this post.

The initial action is performed only once, at the beginning of the loop. The loop condition is a logic statement that will determine if the loop continues. The looping action will be performed at the beginning of each pass through the loop, including the first. Since you seem to understand the while loop, let me rewrite this as a while loop.