How many bytes can I store in one RAM address?
And what is the size of one pointer?
I’m just not sure about these basic concepts and I need a little help. Thank you all.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can typically store one byte per memory location. (Older machines may have used non-octet word sizes, and those machines might store one nibble or 12 or 24 bits per memory location.) But these days, 8-bits is one byte, and one byte is one memory location, though it might not be the word size of the machine.
A pointer’s size may vary: on 32-bit platforms, pointers are usually 4 bytes. On 64-bit platforms, pointers are usually 8 bytes. Older platforms had different sizes of pointers to allow programmers to more closely optimize the memory requirements of their programs. (I’m glad those days are gone.)
What confused me to no end when first starting C is that the memory location referenced by a pointer increments different amounts based on the datatype of the pointer.
When using an offset or incrementing the pointers (
c+1ori+1) the compiler will add1for thechar *pointer and4or8for theint *pointer. My assembler didn’t provide such niceties, and it took me months to get the hang of “the C compiler knows the sizes of types, just trust it”.