So I'm not sure if this is the easiest way to accomplish what my end goal is, so if anyone has a better suggestion, feel free to throw it at me. I've tried searching both on here, and with Google, but I can't seem to figure out how to do this.
I have an array of int values: int bitVal[8]
In my program, each of these values is 1 bit, within a byte. I need to create a loop which goes through each value, and bit shift the value into the int variable.
I tried this as a simple test:
int t = 0;
int e = 1;
for(int i = 0; i < 3; i++) {
t <<= e;
printf("%d\n", t);
}
Now I know that if I had a variable that had a byte value of 0000 0010 and I do var <<= 1; the result will be 0000 0100. Is there a way to set it so the shifted bit is a 1 instead of a 0?
tis0shifting it remains0. The question is not very clear.int bitVal[8]is not in the code snippet, and the loop constraint is the curiousi < 3;.