函数:strrchr()

来源:互联网 发布:云计算应用市场 编辑:程序博客网 时间:2024/04/28 00:06

  strrchr()函数的作用是:查找一个字符串在另一个字符串中末次出现的位置,并返回从字符串中的这个位置起, 一直到字符串结束的所有字符。  如果未能找到指定字符,那么函数将返回NULL。

/* strrchr example */#include <stdio.h>#include <string.h>int main (){  char str[] = "This is a sample string";  char * pch;  pch=strrchr(str,'s');  printf ("Last occurence of 's' found at %d /n",pch-str+1);  return 0;
}