How is a pointer stored in memory? -
i working on os project , wondering how pointer stored in memory? understand pointer 4 bytes, how pointer spread amongst 4 bytes?
my issue is, trying store pointer 4 byte slot of memory. lets pointer 0x7fffffff. stored @ each of 4 bytes?
the way pointer stored same other multi-byte values. 4 bytes stored according endianness of system. let's address of 4 bytes below:
big endian (most significant byte first):
address byte 0x1000 0x7f 0x1001 0xff 0x1002 0xff 0x1003 0xff
small endian (least significant byte first):
address byte 0x1000 0xff 0x1001 0xff 0x1002 0xff 0x1003 0x7f
btw, 4 byte address 32-bit system. 64-bit system has 8 bytes addresses.
edit: reference each individual part of pointer, need use pointer. :) have:
int = 0; int *pi = &i; // pi == 0x7fffffff int **ppi = π // above example, int ppi == 0x1000
simple pointer arithmetic pointer each byte.
Comments
Post a Comment