Obtain last substring of string

May 12, 2008 at 10:30 am | In c language | Leave a Comment
Tags: , ,

#ifdef STRRSTR_MISSING
#ifndef NULL
#define NULL 0
#endif NULL
#ifdef ANSI
char *strrstr(char *s1,char *s2) {
#else
char *strrstr(s1, s2)
char *s1;
char *s2;
{
#endif

char *sc1, *sc2, *psc1, *ps1;

if (*s2 == ”)
return((char *)s1);

ps1 = s1 + strlen(s1);

while(ps1 != s1) {
–ps1;
for (psc1 = ps1, sc2 = s2; ; )
if (*(psc1++) != *(sc2++))
break;
else if (*sc2 == ”)
return ((char *)ps1);
}
return ((char *)NULL);
}
#endif

Blogged with the Flock Browser

Tags: , , , ,

No Comments Yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.