char* my_strstr(const char* x, const char* y) {
if (*y == '\0')
return x;
char* sit[100] = { 0 };
int i = 0;
int j = 0;
while (1) {
if (*x == *y) {
sit[i++] = x;
j++;
}
if (*x == '\0') {
if (sit[0] == 0)
return NULL;
else
break;
}
x++;
}
int count = 0;
for (int n = 0; n < j; n++) {
while (*sit[n] == *y) {
if (*sit[n] == '\0' && *y == '\0')
return sit[n];
sit[n]++;
y++;
count++;
}
if (*y == '\0')
return sit[n]-count;
y = y - count;
count = 0;
}
return NULL;
}
int main() {
char a[20] = "fjjj@kaoyan.com";
char b[20] = "j@kao";
char* c = my_strstr(a, b);
if (c == NULL) {
printf("b不是a的子串");
}
else
printf("%s", c);
return 0;
}