应该怎样看这种if有加循环嵌套的语句呢?
程序代码:#include "string.h"
#include "stdio.h"
main()
{
char str1[20],str2[20],*p1,*p2;
int sum=0;
printf("please input two strings\n");
scanf("%s%s",str1,str2);
p1=str1; //将str1的地址赋给p1
p2=str2;
while(*p1!='\0') //*p1!='\0' 这一句什么意思呢? *p1是取的数组str1的哪个值呢? '\0'是什么意思呢?
{
if(*p1==*p2) //如果str1等于str2,对吗?
{
while(*p1==*p2&&*p2!='\0')
{
p1++;
p2++;
}
}
else
p1++;
if(*p2=='\0')
sum++;
p2=str2;
}
printf("sum=%d\n",sum);
getch();
}
看的都头大啦!应该怎样看这种if有加循环嵌套的语句呢?这个程序输出什么结果呢,哥哥们?









