1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #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[]={"You are so funny"}; char *p; char N[]={"You are So funny!"}; char *q; p=M; q=N; boss(p,q); return 0; } |
Friday, 20 March 2015
Matching String index by index using pointer
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment