I am trying to find a similar function to strstr
that searches a substring starting from the end towards the beginning of the string.
Here is the most minimal simple implantation that I could come up with. Unlike other implementations of this function it avoids the initial strstr call that some other people like user3119703 had.
char * lastStrstr(const char * haystack,const char * needle){
char*temp=haystack,*before=0;
while(temp=strstr(temp,needle)) before=temp++;
return before;
}