...
Removing the dead code depends on the intent of the programmer. Assuming the intent is to flag and process the last character before the NULL
terminator, the conditional is adjusted to correctly determine if the i
refers to the index of the last character has been reachedbefore the NULL
terminator.
Code Block | ||
---|---|---|
| ||
int string_loop(char *str) {
size_t i;
for (i=0; i < strlen(str); i++) {
/* ... */
if (str[i+1] == '\0')
/* This code is now reached */
}
return 0;
}
|
...