...
Code Block | ||
---|---|---|
| ||
size_t count_preceding_whitespace(const char *s) { const char *t = s; size_t length = strlen(s) + 1; /* possibly *t < 0 */ while (isspace(*t) && (t - s < length)) { ++t; } return t - s; } |
Compliant Solution
...
This compliant solution casts the character to unsigned char
before passing it as an argument to the isspace()
function.
...