Pacher R. Dragos a écrit :
Emmanuel Delahaye wrote:
Try a pointer to unsigned char.
/* type ?? */ data = 0xffff;
unsigned char * offset = &data;
cast required. const is a good idea too...
unsigned char const * offset = (unsigned char const *) &data;
/* i haven't tryed this because i need a compatible type */
printf("memory at address %p is %p ", &data, *offset);
printf ("memory at address %p is %02X\n", &data, (unsigned) *offset);
Try that.
#include <stdio.h>
int main (void)
{
int x = 0x1234;
unsigned char const *p = (unsigned char const *) & x;
size_t i;
for (i=0; i < sizeof x; i++)
{
printf("%02X ", p[i]);
}
printf ("\n");
return 0;
}
Note that the result is implementation-dependent.
On my machine(WinTel XP/Mingw)
34 12 00 00