#include <stdio.h>
char *strstr(char *str, char *substr) {
char *pb, *ps;
while (*str) {
pb = str;
ps = substr;
while (*ps) {
if (*pb == *ps) {
pb++;
ps++;
} else {
break;
}
}
if (*ps == 0) {
return str;
}
str++;
}
return NULL;
}
void main() {
char s1[100] = "AABCD123ABCD123ABCDA";
char s2[100] = "123";
printf("%s", strstr(s1, s2));
}
来源:CSDN
作者:轻松的小希
链接:https://blog.csdn.net/qq_38490457/article/details/104639353