比较字符串
#include <stdio.h>#include <string.h>#define LEN 30char * string_in(const char *,const char *);int main(void){ char str1[LEN] = "still loving you"; char str2[LEN/2]; char * find; puts(str1); puts("Please enter str2(empty line to quit)"); while(gets(str2) != NULL && str2[0] != '\0') { find = string_in(str1,str2); if(find) puts(find); else puts("No found"); } puts("Bye"); return 0;}char * string_in(const char * s1,const char * s2){ int x = 1; int l2 = strlen(s2); int l3 = strlen(s1) + 1 - l2; if(l3 > 0) while((x = strncmp(s1,s2,l2)) && l3--) s1++; if(x) return NULL; else return (char *)s1;}