Question: how to calculate hamming distance in c?
Answer: 2 Answers. Hamming distance between two equal length strings, x and y , is defined to be the number of positions where they differ. In the case of x and y being bitstrings, x^y is a string with 1 s in exactly the positions they differ. Thus, HammingDistance(x,y) = Number of 1s in x^y , for bitstrings.