J
James H. Newman
I have the following:
typedef unsigned char T[2] ;
T y = { 0x22, 0x33 } ;
I now define
unsigned short x ;
My question is, can one write an assignment statement such that the two
bytes pointed to by y are copied to x?
Let me first preempt a couple of objections. First, for my
purposes unsigned char is one byte long and unsigned short is two bytes
long. Second, I know how to make the assignment by means of memcpy(), but
I wonder if there is a way of doing it without using the C library, or
putting in place what would amount to a C implementation of memcpy()?
What I have in mind is some casting magic that would do it in a
single assignment statement.
typedef unsigned char T[2] ;
T y = { 0x22, 0x33 } ;
I now define
unsigned short x ;
My question is, can one write an assignment statement such that the two
bytes pointed to by y are copied to x?
Let me first preempt a couple of objections. First, for my
purposes unsigned char is one byte long and unsigned short is two bytes
long. Second, I know how to make the assignment by means of memcpy(), but
I wonder if there is a way of doing it without using the C library, or
putting in place what would amount to a C implementation of memcpy()?
What I have in mind is some casting magic that would do it in a
single assignment statement.