Striker99 0 Newbie Poster

I'm trying to learn C++ on my own so I figured I'd try to write a program for my data communications class. We were learning about hamming codes and I want to try to make a program that will let me do it automatically instead of on paper. I'd take 8-bit binary numbers from a text file and add 4 parity bits for even parity..

A parity bit functions by forcing the sum of a some predetermined set of bits to be an even number (called even parity) or an odd number (called odd parity). In this project, we are interested in even parity. To get the desired effect, the parity bit is set to one or zero according to the sum of the specified original bits. If the selected set of original bits sums to an even number, the extra parity bit is set to zero; if it sums to an odd number, it is set to one. Hence, in either case, the sum -- including the parity bit -- will always be an even number.

For an original message that is 8 bits long, 4 parity bits are added in strategic locations to form a 12-digit message. Each of these additional bits is the parity bit for a different combination of bits in the message, as follows. (Note: for purposes of this problem, bit 1 is defined to be the leftmost bit in the sequence.)

* Parity bit in position 1 combines with bits at positions 3, 5, 7, 9 and 11.
* Parity bit in position 2 combines with bits at positions 3, 6, 7, 10 and 11.
* Parity bit in position 4 combines with bits at positions 5, 6, 7 and 12.
* Parity bit in position 8 combines with bits at positions 9, 10, 11 and 12.

Thus, for instance, if the message to be sent is
10110100
then the message to be sent should be augmented with parity bits as follows

BIT NUMBER 1 2 3 4 5 6 7 8 9 10 11 12
ORIGINAL MESSAGE 1 0 1 1 0 1 0 0
SENT MESSAGE 0 0 1 0 0 1 1 1 0 1 0 0

and it is transmitted as
001001110100
Notice that bit 1 is 0 because the sum of bits 3, 5, 7, and 11 is 1 + 0 + 1 + 0 + 0 = 0, which is an even number. And bit 8 is 1 because the sum of bits 9, 10, 11, and 12 is 0 + 1 + 0 + 0 = 1, which is odd.

I want to take these 3 numbers:
10110100
01010101
10100100

and output them as these:
001001110100
000110100101
111101010100

I was thinking of using infile.get() to get each number as a char through a loop(or multiple) and then finding out whether to make an even or odd parity. I'm kinda lost though.

If anyone has a link to similar code to this that I could look through as an example, that would be helpful as well.