Hi ,so I started on this homework but I'm having trouble finishing it and I was wondering if I could get some help.
heres the code that I have right now:
int main ()
{
short HammingCh, bit1, bit2, bit4, bit8, errantBit;
// ouput ID line
cout << ID;
// read unknown # of short ints, each representing a Hamming character
while (cin >> HammingCh)
{
// intialize errantBit to 0; i.e., assume it has no errors
errantBit = 0;
// if errantBit is nonzero, fix HammingCh
if (errantBit != 0)
{
(11 - errantBit);
}
// build a printable ASCII character from HammingCh
char ch = 0;
ch = setBit(ch, 6, getBit(HammingCh, 11 - 3));
}
return 0;
}
This is the assignment description:
Write a program that decodes the message, correcting for single-bit
errors. The input should be read from standard input (use redirection). The message is of unknown length;
thus, your program should process integers until the end-of-data marker is encountered.
Output
The decoded message should be written to the standard output as characters, not integers.
While I work on your code and see if it will compile. Take a look at the following links.
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
One of the frist things I did notice is that you are missing your header files. Without them I do not know what you have used and the code will not compile.