- strrchr
函数名称: strrchr
函数原型:char *strrchr(char *str, char c);
所属库: string.h
定义及用法:
strrchr函数的作用是:查找一个字符在某个字符串中末次出现的位置,并返回从字符串中的这个位置起,一直到字符串结束的所有字符。如果未能找到指定字符,那么函数将返回NULL。
例子
#include <string.h>
#include <stdio.h>
int main(void)
{
char string[20];
char *ptr, c = 'r';
strcpy(string, "There are two rings");
ptr = strrchr(string, c);
if (ptr)
printf("The character %c is at position: %s\n", c, ptr);
else
printf("The character was not found\n");
return 0;
}
strrchr返回的指针应当指向"rings"里的'r',而不是“There”或"are"里的'r'。
运行结果是:The character r is at position:rings
分享到:
相关推荐
C语言字符串函数大全C语言字符串函数大全C语言字符串函数大全C语言字符串函数大全
C语言字符串函数大全C语言字符串函数大全C语言字符串函数大全C语言字符串函数大全C语言字符串函数大全C语言字符串函数大全C语言字符串函数大全C语言字符串函数大全C语言字符串函数大全C语言字符串函数大全C语言字符...
C语言字符串函数,有需要的可以学习下,挺不错的!很详细,带源代码!
c语言字符串函数大全 c语言字符串函数大全 c语言字符串函数大全 c语言字符串函数大全
各种C语言字符串函数,笔试面试过程中经常被问到的题目
郭天祥C语言字符串函数功能简介郭天祥C语言字符串函数功能简介郭天祥C语言字符串函数功能简介
C语言字符串函数大全(包含示例),很详细的用法
收纳c语言字符串函数,对于你有很大帮助
在面试过程中面试官是不是老叫你写函数实现,给你这个万能的文档。
超级C语言字符串函数大全完整版,对于刚学习C语言的朋友和老用户,它都是你们必备的良友。有了它你可以事半功倍。
C语言字符串函数大全C/C++基础 函数名: stpcpy 功 能: 拷贝一个字符串到另一个 用 法: char *stpcpy(char *destin, char *source); 程序例: #include <stdio.h> #include <string.h> int main(void) ...
c语言字符串函数详解,包含了字符串函数大全,并且对每个函数举例分析及详细解释,不管学习还是开发都是很好的资料
c语言字符串函数详解--函数名及源代码整理
C语言字符串操作函数.docx
C语言字符串函数大全 c标准库里的字符串处理函数。 ps:有时候分享才能得到更多
c语言字符串函数详解