《c程序设计语言》读书笔记-5.4-指针实现strend
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <curses.h> int strend(char *s,char *t) { char *stas = s; char *stat = t; for(;*s;s++) ; for(;*t;t++) ; for(;*s == *t;s--,t--) if(t == stat || s == stas) break; if(*s == *t && t == stat &&*s != '\0') return 1; else return 0; } int main() { char *c = "I love you!";; char *p = "you!" ; int n; n = strend(c,p); printf("%d",n); return 0; }