Chapter 22: Problem 11
The left-shift operator can be used to pack two character values into a twobyte 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 integer 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 characters in their bit format before and after they are packed into the unsigned integer to prove that they are in fact packed correctly in the unsigned variable.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.