#include<stdio.h>
#include<malloc.h>
#define N 100
main()
{
char *pChar1,*pChar2;
int len;
bool flag=true;
printf("input string1:\n");
pChar1=(char *)malloc(sizeof(char)*N);
gets(pChar1);
printf("input string2:\n");
pChar2=(char *)malloc(sizeof(char)*N);
gets(pChar2);
for(int i=0;i<(strlen(pChar1)<strlen(pChar2)?strlen(pChar2):strlen(pChar1));i++)
{
if(pChar1[i]!=pChar2[i])
{
flag=false;
printf("%c %c\n",pChar1[i],pChar2[i]);
break;
}
}
if(flag)
printf("0\n");
free(pChar1);
free(pChar2);
}
不知符合否?