#include
#include
main()
{char str1[100],str2[100];
int i=0;
printf("enter the first string\n");
scanf("%s",str1);
printf("enter the second string\n");
scanf("%s",str2);
while(str1[i]!='\0' &&str2[i]!='\0' )
{ if( str1[i]!= str2[i] ) break;
else i++;}
printf("%d \n",str2[i]-str1[i]);
}
咯咯
#include
int cmp(char a[],char b[]);
main()
{
char a[100]="giggle",b[100]="gigglf";
printf("%d",cmp(a,b));
printf("\n");
}
int cmp(char *p,char *q)
{
while(*p==*q&&*p&&*q){p++;q++;}
return *p-*q;
}