Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,938 questions

51,875 answers

573 users

How to implement the strrstr function in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>

char* strrstr(const char* haystack, const char* needle) {
    char* result = NULL;
    char* current = strstr(haystack, needle);
    
    while (current) {
        result = current;
        current = strstr(current + 1, needle);
    }
    
    return result;
}

int main() {
    const char* str = "C#:C C++:Java:C: Python";
    
    char* p = strrstr(str, "C");
    
    printf("%s\n", p);

    return 0;
}



/*
run:

C: Python

*/

 



answered Aug 2, 2024 by avibootz

Related questions

1 answer 56 views
56 views asked Jun 10, 2025 by avibootz
1 answer 112 views
1 answer 109 views
2 answers 198 views
198 views asked Jan 7, 2024 by avibootz
1 answer 109 views
1 answer 114 views
114 views asked Dec 25, 2022 by avibootz
1 answer 89 views
89 views asked Dec 20, 2022 by avibootz
...