I'm trying to write a small program that will generate a parity bit for Hex and Binary values pulled from an ASCII character array. I have a total of 3 character arrays. For example:
const char *caASCII[] = {"A", "B", "C", ...};
const char *caASCIIBinary[] = {"01000001", "01000010", "01000011", ...};
const char *caASCIIHex[] = {"41", "42", "43", ...};
So, I type "A" and it finds the corresponding values in the Binary and Hex arrays and then displays them. I have a linear search function that does the search and it works fine.
I want to know if it's possible to count, for example, the number of times that "1" occurs in one of the binary values and then judging from that (if the number of 1s is even or odd) add a "0" or a "1" at the end of the binary value. The hex values I guess I would have to divide by 2 to see if it's even or odd.
I'm starting to think that I would have to change the arrays to a different type, probably integer. Any suggestions as to how I can approach this?