Modifying a control variable is a very confusing practice - bugs can easily be introduced when the code is enhanced later on in the software cycle. If one control variable depends directly on another, it is clearer to make this dependency explicit.
Example:
/* confusing: */
for (i = 0; text[i] != '\0'; i++)
{
...(i++)...(i--)... /* assuming left to right evaluation */
}
/* make the dependency clear: */
for (i = 0; text[i] != '\0'; i++)
{
...i...(i+1)...
}
/* or, if the formula is more complex: */
for (i = 0; text[i] != '\0'; i++)
{
const int j = ...i...;
...i...j...
}
|