# include & ltstdio.h & gt
int rfind(const char*source,const char * match);
void main()
{
/* char * source test = " 1230123 ";
char * match test = " 123 ";
Printf("搜索的最終結果是:\ n ");
printf("%d ",rfind(sourcetest,match test));
getch();*/
char * source 1;
char * match 1;
Printf("請輸入原字符:\ n ");
scanf("%s ",source 1);
Printf("請輸入匹配字符串:\ n ");
scanf("%s ",match 1);
Printf("搜索的最終結果是:\ n ");
printf("%d\n ",rfind(source1,match 1));
getch();
}
int rfind(const char*source,const char* match)
{
char * p;
int n = 0;
p =源;
/*讓指針p指向最後壹個位置*/
for(;*p!= '\0';p++)
{
n++;
}
for(;n & gt0;n -)
{
if(*p == *match)
{
return(strlen(p)+1);
}
p-;
}
return-1;
}