The exercise asks me to do:
"The left-shift operator can be used to pack two character values into an unsigned integer variable. Write a program that inputs two characters from the keyboard and passes them to function packCharacters. To pack two characters into an unsigned intger variable, assign the first character to the unsigned variable, shift the unsigned variable left by 8 bit positions and combine the unsigned variable with the second character using the bitwise inclusive OR operator. The program should output the character in their bit format before and after they are packed into the unsigned integer to prove that the characters are in fact pakced correctly in the unsigned variable."
How would I use an OR operator to combine two chunks of bits? My understanding is the OR operator will return the data-type filled with 1's if it evaluates true and all 0's if it evaluates false. It just doesn't make sense to me to want to do that. You can left shift the unsigned int, and then do a simple addition of the second character( after converting to int ). What am I missing?