Error Detection and Correction

This is a discussion on Error Detection and Correction within the C Programming forums, part of the General Programming Boards category; Hi, I am making an application for "The Hamming Code". I am having some problems I don't understand how to ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    21

    Error Detection and Correction

    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:

    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"
    I can read the chracter and convert it to binary but I am stuck afterwards.
    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;
    
    }
    Thanks alot for help.
    Daisy

  2. #2
    Registered User
    Join Date
    Feb 2006
    Posts
    21
    I don't need the solution just a good start.

  3. #3
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Try saving the converted binary into an array or similar structure. Then displaying and flipping will be easy.

  4. #4
    Registered User
    Join Date
    Feb 2006
    Posts
    21
    how do I store that in two dimensional array?

  5. #5
    Slave MadCow257's Avatar
    Join Date
    Jan 2005
    Posts
    735
    Why would you use a 2D array?

  6. #6
    Registered User
    Join Date
    Feb 2006
    Posts
    21
    this is a requirement of my assign.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. need correction
    By Lissa in forum C Programming
    Replies: 7
    Last Post: 10-24-2008, 03:53 PM
  2. Want correction
    By Russian_Thia in forum C++ Programming
    Replies: 6
    Last Post: 10-06-2006, 03:09 PM
  3. needs a correction
    By threahdead in forum C Programming
    Replies: 5
    Last Post: 10-16-2002, 08:58 PM
  4. Encryption/Decryption -- Correction
    By Abdi in forum C++ Programming
    Replies: 0
    Last Post: 04-28-2002, 08:00 AM
  5. pls help with the correction...
    By leena_teoh in forum C Programming
    Replies: 1
    Last Post: 03-20-2002, 04:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21