代码如下
#include
#include
main()
{
int i = 0;
char str[20];
char str1[20];
printf("Please enter a character string,:");
scanf("%s", str);
printf("Please enter a search term.:");
scanf("%s", str1);
while (strstr(str, str1) != NULL) {
i++;
strstr(str, str1);
}
printf("Ans=%d", i);
}
有几个问题想问 1为什么一直处于无限循环的状态 2strstr(str,str1)这个写法对不对 比如str=seed str1=ee,如果想把str的值变为第一次strstr操作之后的结果 也就是 seed-e 该如何操作