- strrstr( ) function returns pointer to the last occurrence of the string in a given string. Syntax for strrstr( ) function is given below.
char *strrstr(const char *str1, const char *str2);
- strrstr( ) function is non standard function which may not available in standard library in C.
Example program for strrstr() function in C:
- In this program, strrstr( ) function is used to locate last occurrence of the string “test” in the string ”This is a test string for testing”. Pointer is returned at last occurrence of the string “test”.
#include <stdio.h> #include <string.h> int main () { char string[55] ="This is a test string for testing"; char *p; p = strrstr (string,"test"); if(p) { printf("string found\n" ); printf ("Last occurrence of string \"test\" in \"%s\" is"\ " \"%s\"",string, p); } else printf("string not found\n" ); return 0; }
Output:
string found
Last occurrence of string “test” in “This is a test string for testing” is “testing” |
C – Strrstr() Function ~ Computer Science Magazine >>>>> Download Now
ReplyDelete>>>>> Download Full
C – Strrstr() Function ~ Computer Science Magazine >>>>> Download LINK
>>>>> Download Now
C – Strrstr() Function ~ Computer Science Magazine >>>>> Download Full
>>>>> Download LINK