Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NEED HELP with bit string mesage encoder and decoder.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm just starting in c++ and have no prier experience with bit strings so if any one could help me I would be more then thankful.
Here is my problem:
I need to write a program that takes a message from the user, generate some random noise using rndom number generator to simulate a noisy communication channel. Then I need to generate a bit string representation of the original message, and the randomly created noise. Than I need to generate the bit string representation of the received message, bit string representation of the error corrected message and the error corrected message(wich should be the same message as the original one)

Basicly I need to write an encoder and a decoder with the decoder capable of repairing the distorted message. Using random number generator to simulate a noisy communication channel. The output should look something like this:

~The original message
~Bit string representation of the original message
~Bit string representation of the noise
~Bit string representation of the message received
~Bit string representation of the error corrected message
~The error corrected message

There are couples of different algorithms that can be used to solve this problem. As I said before I never used bit strings or for that matter algorithms below before:

Parity check -
Triple repetition code repeats a message three times- Or to repeat each bit in a message twice, e.g., 11011001 is encoded as 1111001111000011.

Thank you

Dani G
 
basically you can use the char array to represent your bit stream.
char aStream[1000];

to convert a number into a bit stream, you need to write your own code, here is a sample :
numberToString(char *aStream, unsigned long aNum){
for (int i = 0; i<64;i++){
if (aNum && 1) aStream[63 - i] = '1';
else aStream[63 -i] = '0';
aNum >> 1;
}
}

And you may need to convert a bitstream into a number:
StringToNumber(char *aStream, unsigned long& aNumber){
aNumber = 0;
for (int i = 0;i < 64 ;i++){
if (aStream == '1') aNumber +=1;
aNumber << 1;
}
}

use the string operation functions such as strcpy, strcat, strcmp to operate the string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top