...
In this example, the strlen() function is used to limit the number of times the function string_loop() will iterate. However, the programmer mistakenly subtracts 1 from the result of strlen(). As a result, the last character before the NULL byte terminating null character will never be processed.
| Code Block | ||
|---|---|---|
| ||
int string_loop(char *str) {
size_t i;
for (i=0; i < strlen(str)-1; i++) {
/* Process str */
}
return 0;
}
|
...