// Declaration of data type where 4 bytes are packed into an unsigned.
int xbyte(packed_t word, int bytenum);
int main()
{
int bytenum = 0;
typedef unsigned packed_t;
packed_t word;
}
// Extract byte from word, return as signed integer.
int xbyte(packed_t word, int bytenum)
{
// Failed attempt at xbyte
return ( word >> (bytenum << 3)) & 0xff;
}
I am unsure how to declare the packed_t in this question. I am supposed to use the prototype from the top. How does word even come into play. I am lost this is part of a homework assignment.
You already have a
typedefline. Make it the first line of this piece of code, and you are done. The basic thing is that thetypedefed name must be visible everywhere you use it.