#include
#include
int main (void) {
char str1[80] = "Hello";
char str2[80] = "Hello";
char str3[80] = "world";
char *des ,*src;
int isDiff=0, diff=0;
des = str1;
src = str3;
while (*des && *src) {
if (*des != *src) {
isDiff = 1;
diff = *des - *src;
break;
}
des++;
src++;
}
printf ("%s与%s是否相同?相同:0;不相同1 -> %d\n", str1, str3, isDiff);
if (isDiff)
printf ("不同字符 -> %c-%c = %d\n", *des ,*src, diff);
getch ();
return 0;
}
运行结果