Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.
void params() {
printf("Enter the length of the Hamming code: ");
scanf("%d", &hamming_length);
printf("Enter the parity (o=even, 1=odd): ");
scanf("%d", &parity_type);
hamming = (char *) malloc (hamming_length * sizeof(char));
return;
}
/* Option #2 */
void check_hamming_code() {
/* declare local var's */
int i,j,k;
/* prompt for hamming code string */
printf("Enter the Hamming code: ");
scanf("%s",hamming);
for(i=1; i < hamming_length; i*=2) {
/* init. something in i */
int current_parity = parity_type;
for(j=i; j <= hamming_length; j+=2*i) {
/* init. something in j */
for(k=j; (k <= hamming_length) && (k < i+j); k++) {
if(k != i)
current_parity = current_parity ^ hamming[hamming_length-k];
} /* end of k loop */
} /* end of j loop */
error_bit = error_bit + (current_parity ^ (hamming[hamming_length-i]-'0'))*i;
} /* end i loop */
/* correct error bit */
printf("%d",error_bit);
return;
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
ASP.net build a IF/Then Walkthrough Guide | 1 | 209 | |
Unresolved External Symbols | 3 | 80 | |
Arduino EDI - Programming language | 3 | 91 | |
What is atomic operation? | 6 | 58 |
Join the community of 500,000 technology professionals and ask your questions.