English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Bibliothèque standard C - <string.h>
C 库函数 char *strrchr(const char *str, int c) 在参数 str 所指向的字符串中搜索最后一次出现字符 c(一个无符号字符)的位置。
下面是 strrchr() 函数的声明。
char *strrchr(const char *str, int c)
该函数返回 str 中最后一次出现字符 c 的位置。如果未找到该值,则函数返回一个空指针。
下面的示例演示了 strrchr() 函数的用法。
#include <stdio.h> #include <string.h> int main () { int len; const char str[] = "https:";//fr.oldtoolbag.com"; const char ch = '.'; char *ret; ret = strrchr(str, ch); printf("|%c| Les chaînes de caractères suivantes sont"} - |%s|\n", ch, ret); return(0); }
Compilons et exécutons le programme suivant, ce qui produira le résultat suivant :
|.| Les chaînes de caractères suivantes sont - |.com|