Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int strdiff(char* a, char* b){
- int index = 0;
- while(a[index] != '\0' && b[index] != '\0' && a[index] == b[index])
- index++;
- if(a[index] == '\0' && b[index] == '\0')
- return -1;
- char val = a[index]^b[index];
- int i = 0;
- while(val){
- if(val&1)
- return 8*index+i;
- val = val >> 1;
- i++;
- }
- }
- int main(int argc, char **argv)
- {
- char s1[1000], s2[1000];
- gets(s1);
- gets(s2);
- printf("%d\n", strdiff(s1, s2));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement