在KIEL C51上调试通过。改过的程序如下:
#include
void main(){
char str1[10], str2[10];
int j,flag;
printf("\n");
scanf("%s%s",str1,str2);
while (str1[j]==str2[j])
{
j++;
if (str1[j]=='\0'||str2[j]=='\0')
{
break;
}
}
if (str1[j]=='\0'&&str2[j]=='\0')
{
flag=0;
}
else
{
flag=1;
}
if (flag)
{
printf("the two string are equal.");
}
else
{
printf("the two string are not equal.");
}
}
#include
void main()
{
char str1[10], str2[10];
int j=0, flag;
printf("\n");
scanf("%s%s", &str1[10],&str2[10]);
while(str1[j] == str2[j])
{
j++;
if (str1[j]=='\0' || str2[j]=='\0')
break;
}
if(str1[j]=='\0'&&str2[j]=='\0')
flag= 1;
else
flag = 0;
if(flag)
printf("the two string are equal.");
else
printf("the two string arenot equal.");
system("pause");
}