/* returns the position of the rightmost occurrence of t in s, or -1 * if there is none */ int strrindex(char s[], char t[]) { int pos, i; pos = -1; for (i = 0; s[i] != '\0'; i++) { for (j=i, k=0; s[j] == t[k] && t[k] != '\0'; j++, k++) ; if (k > 0 && t[k] == '\0') pos = i; } return pos; }