T
Test
I have:
int xx;
char *buf;
buf is pointed to a string with int values, for example:
buf=(char *)malloc(4);
buf[0]=0;
buf[1]=0;
buf[2]=178;
buf[3]=3;
etc.
I want xx to have the int value of 946 from buf[2] and buf[3].
I can do it like this:
memcpy( &xx, &buffer[2], 2 );
or
((char *)(&xx))[0]=buffer[2];
((char *)(&xx))[1]=buffer[3];
Both look clumsy. How would I cast it more elegantly.
My target is win32 if that matters.
int xx;
char *buf;
buf is pointed to a string with int values, for example:
buf=(char *)malloc(4);
buf[0]=0;
buf[1]=0;
buf[2]=178;
buf[3]=3;
etc.
I want xx to have the int value of 946 from buf[2] and buf[3].
I can do it like this:
memcpy( &xx, &buffer[2], 2 );
or
((char *)(&xx))[0]=buffer[2];
((char *)(&xx))[1]=buffer[3];
Both look clumsy. How would I cast it more elegantly.
My target is win32 if that matters.