hamming.c (290B)
1 #include <stdio.h> 2 #include <string.h> 3 4 int compute(char* s1, char* s2) { 5 if (s1 == NULL || s2 == NULL || strlen(s1) != strlen(s2)) { 6 return -1; 7 } 8 int distance = 0; 9 for (int i = 0; s1[i] != '\0'; i++) { 10 if (s1[i] != s2[i]) { 11 distance++; 12 } 13 } 14 return distance; 15 }