I am trying to make a hamming code decoder and encoder in C and I cannot find a way to set the bits of a variable individually.
For example, I am trying to somehow do the following:
#include "stdio.h"
int main () {
short block = 0010101110001110; // variable to contain the bits to decode
}
Clearly this will not work but I am wondering if there is a way to do this or will I have to define it as the actual number this represents?
You can use hexadecimal representation, where each digit represents exactly 4 bits.
unsigned short block = 0x2b8e;