Matching Two String using Pointer

No comments

#include<stdio.h>
void boss(char *l,char *m)
{
int i=0,j=0;
while (*(l+i)!='\0' && *(l+j)!='\0')
{
if ((*(l+i)==*(m+j))||(*(l+i)==' '&&*(m+j)==' ' ))
{
i++;j++;}
else{
break;

}
}
if( (*(l+i)==*(m+j)))
{printf("same\n");}
else{printf("position: %d\n",i);
printf("position: %d\n",j);
printf("\"%c\" <not match>  =  ",*(l+i));
printf("\"%c\"\n",*(m+j));
}

}
int main(void) {
char M[]={"Bangladesh very ajob desh"};
char *p;
char N[]={"Bangladesh very gajob desh"};
char *q;
p=M;
q=N;
boss(p,q);

return 0;
}

No comments :

Post a Comment