1

Being a beginner in C, I was aware that pointers are a special data type used to store the address of a data type. If I calculate size of any pointer in my PC (64-bit OS) it's 8 bytes.

In memory representation each address represents 1 byte (byte-addressing... I read it on Wikipedia), so it means that a pointer will occupy 8 contiguous blocks of memory just like an integer does (4 bytes)? And if we print the address that the pointer stores; will it be the base address of those 8 bytes?

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
hell_coder
  • 29
  • 6
  • 2
    No, it isn't the address where the pointer is stored; it is the address where something *else* is stored. – Weather Vane May 13 '23 at 13:14
  • ... and "the base address of those 8 bytes" is a "pointer to a pointer". – Weather Vane May 13 '23 at 15:41
  • @WeatherVane, I can't understand, can you please explain briefly. – hell_coder May 13 '23 at 19:00
  • A pointer points to an object. The pointer is itself an object, so a pointer to a pointer means "a pointer to another pointer". A pointer is the *address* of something, an analogy is say your home address. If you write that address down and place it in a cupboard, and then tell your friend where the cupboard is, they have a pointer to a pointer. You might like to read SO's [What are the barriers to understanding pointers and what can be done to overcome them?](https://stackoverflow.com/questions/5727/what-are-the-barriers-to-understanding-pointers-and-what-can-be-done-to-overcome) – Weather Vane May 13 '23 at 19:13
  • @WeatherVane, I now understand; thank you but what is the sense of size of pointer being 8 bytes? – hell_coder May 18 '23 at 09:54
  • So that the 64-bit compiler can access the 64-bit (virtual) address space. With a 32-bit compiler you can only access a 32-bit memory space, even if the computer has a 64-bit address space. – Weather Vane May 18 '23 at 15:32

0 Answers0