Chinaunix首页 | 论坛 | 博客
  • 博客访问: 392383
  • 博文数量: 103
  • 博客积分: 3073
  • 博客等级: 中校
  • 技术积分: 1078
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-23 15:04
文章分类

全部博文(103)

文章存档

2012年(13)

2011年(76)

2010年(14)

分类: LINUX

2011-08-17 11:44:38

strrchr
function
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个也是也可以的。:)
  1. #include <string.h>

  2. int
  3. strncmp(s1, s2, n)
  4.     register const char *s1, *s2;
  5.     register size_t n;
  6. {

  7.     if (n == 0)
  8.         return (0);
  9.     do {
  10.         if (*s1 != *s2++)
  11.             return (*(const unsigned char *)s1 -
  12.                 *(const unsigned char *)(s2 - 1));
  13.         if (*s1++ == 0)
  14.             break;
  15.     } while (--n != 0);
  16.     return (0);
  17. }

阅读(600) | 评论(0) | 转发(0) |
0

上一篇:strtok

下一篇:extern c vs static

给主人留下些什么吧!~~