Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void decodeHamming(char* msg, int len)
- {
- int i;
- char* aux = (char*)malloc(2 * len * sizeof(char));
- for (i = 0; i < 2 * len; i++)
- aux[i] = msg[i];
- for (i = 0; i < len; i++) {
- setBit(&msg[i], 0, getBit(aux[2 * i], 6));
- setBit(&msg[i], 1, getBit(aux[2 * i + 1], 0));
- setBit(&msg[i], 2, getBit(aux[2 * i + 1], 1));
- setBit(&msg[i], 3, getBit(aux[2 * i + 1], 2));
- setBit(&msg[i], 4, getBit(aux[2 * i + 1], 4));
- setBit(&msg[i], 5, getBit(aux[2 * i + 1], 5));
- setBit(&msg[i], 6, getBit(aux[2 * i + 1], 6));
- setBit(&msg[i], 7, getBit(aux[2 * i + 1], 7));
- }
- free(aux);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement