Hi,
I am making an application for "The Hamming Code". I am having some problems I don't understand how to do this. The user can only put up to 5 characters. then the user will put the bit to flip.the output should look something like this:
I can read the chracter and convert it to binary but I am stuck afterwards.Code:Input a word to transmit: B <enter> Input a bit to flip: 12 <enter> Processing… - Transmitting character "B" with binary code 0100 0010 - The parity bits are: Bit 1 2 4 8 1 1 1 0 - The encoded array is: Bit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 Sending…. It is being corrupted by flipping bit 9. - The corrupted array is: Bit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 0 0 1 0 0 0 0 0 1 1 0 0 0 The corrupted character at destination is "C" The checksum for parity bits is: Bit 1 2 4 8 1 1 0 0 The corrected character is "B"
Thanks alot for help.Code:#include <stdio.h> char ascitobinary(); int main(void){ ascitobinary(); } char ascitobinary(){ char x ; int y; printf("Input a word to transmit: " ); scanf("%c",&x); for(y = 0; y < sizeof(char) * 15; y++) printf("%c ", ( x & (1 << y) ) ? '1' : '0' ); puts(""); return 0; }
Daisy![]()



LinkBack URL
About LinkBacks



