The strrchr () function in C
Char * strrchr (const char * str, int c) looks for the last occurrence of the character c (an unsigned char) in the string pointed to by parameter str.
Char * strrchr (const char * str, int c) looks for the last occurrence of the character c (an unsigned char) in the string pointed to by parameter str.
Declaring strrchr () function in C
Here is the declaration for strrchr () in C:
char * strrchr ( const char * str , int c )
Parameters
str - A string.
c - This is the character to be located. It is transmitted in int form, but internally it is converted back to char.
Returns the value
This function returns a pointer to the last occurrence of the character in str. If the value is not found, the function returns a null pointer.
For example
The following C program illustrates the usage of strrchr () in C:
#include #include int main () { int len ; const char str [] = "https://QTM.com/lap-trinh-c/index.jsp" ; const char ch = '.' ; char * ret ; ret = strrchr ( str , ch ); printf ( "Chuoi xuat hien sau dau |%c| cuoi cung la: n|%s|n" , ch , ret ); return ( 0 ); }
Compiling and running the above C program will result:
According to Tutorialspoint
Previous article: Function strpbrk () in C
Next lesson: strspn () function in C
You should read it
- Memset () function in C
- Strcpy () function in C
- Memmove function in C
- Function strxfrm () in C
- The strcoll () function in C
- The function strcmp () in C
- The function strncmp () in C
- The strstr () function in C
- The function strpbrk () in C
- The strtok () function in C
- Strcat function in C
- The strlen () function in C
Maybe you are interested
Revealing new findings about the size of the galaxy Admire incredibly detailed images of the Orion Nebula through the eyes of the James Webb telescope This star 'tears up' its companion to create a rare beautiful nebula Galaxy merger moment gives glimpse into Milky Way's future Science has discovered the fastest-flying star in the Milky Way, reaching 8% of the speed of light Discovered organic molecules that can make life in the center of the Milky Way