int indexof(const char *s1, const char *s2)
{
int length1, length2;
const char *tmp = s1;
length2 = strlen(s2);
if (!length2)
{
/* code */
printf("The s2 is NULL!.\n");
exit(1);
}
length1 = strlen(tmp);
while(length2 <= length1)
{
length1--;
if (!memcmp(tmp, s2, length2))
{
/* code */
return (tmp - s1);
}
tmp++;
}
return -1;
}