Because there's already a perfectly good way to find the terminator (&p[strlen(p)]
) and because if strchr() didn't find the '\0', I could do things like
while (strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", *p) == NULL)
p++;
to move to the first character that's not an uppercase letter. Instead I have to do
while (*p != '\0' && strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", *p) == NULL)
p++;
Being able to use strchr() for determining if a character is a member of a set of characters would be far more useful than using strchr(s, '\0')
as a synonym for &s[strlen(s)]
. And yeah, I can still do it, but the extra pointless comparison is annoying, since this is the kind of thing I normally use strchr to do.