| Functions | |||||||||||||||||||||||||||||||||||||||||
| Character manipulation | |||||||||||||||||||||||||||||||||||||||||
| Conversions to and from numeric formats | |||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||
| String manipulation | |||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||
| String examination | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
| Memory manipulation | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
| Miscellaneous | |||||||||||||||||||||||||||||||||||||||||
(C11)(C11) | |||||||||||||||||||||||||||||||||||||||||
Defined in header <string.h> | ||
char* strrchr(constchar* str,int ch); | (1) | |
/*QChar*/* strrchr(/*QChar*/* str,int ch); | (2) | (since C23) |
T be an unqualified character object type.str is of typeconst T*, the return type isconstchar*.str is of typeT*, the return type ischar*.The behavior is undefined ifstr is not a pointer to a null-terminated byte string.
Contents |
| str | - | pointer to the null-terminated byte string to be analyzed |
| ch | - | character to search for |
Pointer to the found character instr, or null pointer if no such character is found.
#include <stdio.h>#include <string.h> int main(void){char szSomeFileName[]="foo/bar/foobar.txt";char* pLastSlash= strrchr(szSomeFileName,'/');char* pszBaseName= pLastSlash? pLastSlash+1: szSomeFileName;printf("Base Name: %s", pszBaseName);}
Output:
Base Name: foobar.txt
| finds the first occurrence of a character (function)[edit] | |
| finds the first location of any character in one string, in another string (function)[edit] | |
C++ documentation forstrrchr | |