计算字符串中子串出现的次数,改正程序中的2个错误,使程序能输出正确的结果。不要改动main函数,不得删行减行
ge342.c;
#include"string.h"
#include"stdio.h"
main()
{char str1[20],str2[20],*p1,*p2;
int sun=0;
printf("please input two strings\n");
scanf("%s%s",str1,str2);
p1=str1; p2=str2;
while(*p1!='\0')
{
if(*p1= =*p2||*p2!='\0')
{p1+ +;
p2+ +;}
}
else
p2+ +
if(*p2= ='\0')
Sum+ +;
p2=str2
}
printf("/d\n",sum);
geteh();
}
|