[C Language] enter multiple lines of information on the terminal to find the lines containing the "ocould" and print and modify the lines.
#define _CRT_SECURE_NO_WARNINGS 1#include<stdio.h>#include<assert.h>#include<stdlib.h>#define MAX 1000 char *my_strstr(const char *dst,const char *src){ assert(dst); assert(src); char *p = dst; char *s1 = p; char *s2 = src; while (*s1) { s1 = p; s2 = src; while ((*s1!='\0')&&(*s2 != '\0')) { if (*s1++ == *s2++) { ; } else { p++; break; } } if (*s2 == '\0') { return p; } } return NULL;}int getline(char *line, int limit){ assert(line); char ch = 0; int i = 0; while (limit-- && ((ch = getchar()) != EOF) && ch != '\n') { line[i++] = ch; } if (ch == '\n') { line[i++] = '\n'; } line[i] = '\0'; return i;}int main(){ /*char *str1 = "abbbcdef"; char *str2 = "bbcd"; char *ret = my_strstr(str1, str2); printf("%s\n", ret);*/ char *str1 = "ould"; char line[MAX] = { 0 }; while (getline(line, MAX - 1)) { if (my_strstr(line, str1)) { printf("%s\n", line); } } system("pause"); return 0;}