Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFCCCC
int string_loop(char *str) {
    size_t i;
    for (i=0; i < strlen(str)-1; i++) {
        /* Process str */
    }
    return 0;
}

Compliant Solution 2

In this case, removing the dead code requires us to adjust the terminating condition of the loop so that every element in str is processed. This can be done by not subtracting 1 from the result of strlen().

Code Block
bgColor#ccccff
int string_loop(char *str) {
    size_t i;
    for (i=0; i < strlen(str); i++) {
        /* Process str */
    }
    return 0;
}

...