I've been asked to write some code that is unlike anything I've had to do before, so I'm looking for suggestions on how I should go about doing this.
I need to have an 8-bit string where the first 4-bits represent the command (either erosion or dilation of an image...those 2 functions are already written) and the last 4-bits represent the one parameter that those functions take (an int value representing the size). I have to pass that string into a new function that calls either the erosion or dilation methods based on the first 4-bits of the string with the appropriate parameter from the last 4-bits of the string. The 8-bit string is terminated at null with all 0's. The person who explained it to me is not in for a few days, so I'm at a big dilemma, and don't know where to begin. He wrote down that the 8-bit string could look like this:
command | parameter
0001 0001 (i think this one represented erosion)
and that the 8-bit string could be hard coded for now for testing purposes. I just don't understand how the method that I need to write will be able to "extract" the first 4-bits to represent either the erosion or dilation method and then "extract" the last 4-bits for the parameter and also know if there are multiple commands within the string and handle those until there is a null terminator. I'm not even sure how he wants me to hard code this string. Do I represent it with the binary representation? If anybody has any idea of where I could start with this, it would be really appreciated. Thanks