const char * strrchr ( const char * str, int character );
char * strrchr ( char * str, int character );
Locate last occurrence of character in string
Returns a pointer to the last occurrence of
character in the C string
str.
The terminating null-character is considered part of the C string.
Therefore, it can also be located to retrieve a pointer to the end of a
string.
即使n 大于字符串其中之一的长度也是可以的。
大于2个也是也可以的。:)
- #include <string.h>
-
-
int
-
strncmp(s1, s2, n)
-
register const char *s1, *s2;
-
register size_t n;
-
{
-
-
if (n == 0)
-
return (0);
-
do {
-
if (*s1 != *s2++)
-
return (*(const unsigned char *)s1 -
-
*(const unsigned char *)(s2 - 1));
-
if (*s1++ == 0)
-
break;
-
} while (--n != 0);
-
return (0);
-
}
阅读(635) | 评论(0) | 转发(0) |