Originally posted by ylzhang
What is the bit length a unique memory address occupies -- one byte?
All pointers have the same size, no matter what they point to. The size of a pointer will be the size of the address bus - on a 32bit machines, this is 32bits or 4 bytes - on a 64bit machines, this is 64bits or 8bytes. Consider the following code:
Code:
printf ("%d\n",sizeof(char*));
printf ("%d\n",sizeof(int*));
printf ("%d\n",sizeof(long*));
printf ("%d\n",sizeof(float*));
printf ("%d\n",sizeof(double*));
printf ("%d\n",sizeof(void*));
These are all 4 on my 32bit system.
Originally posted by stumon
Just to add in, pointers are unsigned integers.
To be more precise, a pointer is of integral type (ie. a whole number), the size of which depends on the width of your address bus. The size of an "unsigned integer" on a 64bit machine is 4bytes, the size of a pointer is 8 bytes.
So, a pointer is the same no matter what it points to. The type that the pointer points to determines how many bytes are accessed when the pointer is dereferenced. For example, when you dereference a "char*", 1 byte is accessed at the memory address in the pointer. When you dereference a "int*", 4 bytes are accessed at the memory address in the pointer.
Originally posted by ylzhang
The reason I'm converting a 32-bit code to 64-bit is to use more memory. The current code (compiled for 32-bit system) can only use up to 2 gb of memory.
A 32-bit system can potentially address up to 4gig (2^32 bytes) of memory. A 64-bit system can address up to 2^64 bytes of memory.
Here is a tutorial on pointers.
gg