// 模拟库函数strstr#include#include const char* my_strstr(const char *parent, const char *child){ const char *pgo = parent; const char *cgo = child; const char *pgos = parent; assert(parent != NULL && child != NULL); if (!*child) { return NULL; } while (*pgo) { pgo = pgos; cgo = child; while (*pgo == *cgo && *pgo && *cgo) { pgo++; cgo++; } if (*cgo == '\0') return pgos; pgos++; } return NULL;}int main(){ printf("%s\n", my_strstr("hhhww", "hhww")); printf("%s\n", my_strstr("zhaoyaqian","aoya")); printf("%s\n", my_strstr("abc", "aefg")); return 0;}