C库函数:strpbrk() 的实现一问# Programming - 葵花宝典
f*n
1 楼
这是glibc 2.6 的实现.
/* Find the first occurrence in S of any character in ACCEPT. */
char *
strpbrk (s, accept)
const char *s;
const char *accept;
{
while (*s != '\0')
{
const char *a = accept; // *** my comment: unnecessary! ???
while (*a != '\0')
if (*a++ == *s)
return (char *) s;
++s;
}
return NULL;
}
I don't understand why there is an extra temp variable "a" defined at ***.
Why don't we just use accept? Anyway, changes made to accep
/* Find the first occurrence in S of any character in ACCEPT. */
char *
strpbrk (s, accept)
const char *s;
const char *accept;
{
while (*s != '\0')
{
const char *a = accept; // *** my comment: unnecessary! ???
while (*a != '\0')
if (*a++ == *s)
return (char *) s;
++s;
}
return NULL;
}
I don't understand why there is an extra temp variable "a" defined at ***.
Why don't we just use accept? Anyway, changes made to accep