#include <stdio.h> #include <string.h> int strrindex(char s[], char t[]){ int i, j, k; int len = strlen(s); for (i = len - 1; i >= 0; i++) { for (j = i, k = 0; t[k] != 0 && s[j] == t[k]; j++, k++); if (k > 0 && t[k] == '\0') return i; } return -1; } int main() { char t[] = "rld"; char s[] = "hello, world!"; int pos; pos = strrindex(s, t); printf("%d",pos); return 0; }
标签:返回,return,strrindex,int,++,pos,char,最右 From: https://www.cnblogs.com/cjxs0/p/17303120.html