c strstr
#include <stdio.h> int strend(char *s , char *t) { char *temp = s; while(*temp != '\0') { char *tmp1 = temp; char *t1 = t; while(*t1 != '\0' && *tmp1 != '\0') { if(*t1 != *tmp1) break; if(*t1 == *tmp1 && *(t1+1)=='\0') return 1; //若相等则继续比较下一个字符 if (*t1 == *tmp1) { t1++; tmp1++; } } temp++; } return 0; } int main(int argc, char *argv[]) { char str[] = "hello world"; char des[] = "wor"; int res = strend(str,des); printf("res:%d\n",res); return 0; }