Suppose I create an array of integers. The name of the array is a pointer to the first element in the array.
If I add 1 to this pointer, it will jump to the next integer in the array. The address itself will increase by 4, the number of bytes in an integer.
How does the computer know that when I write:
++pointer;
it must increase the address by 4?
A pointer contains only an address. It does not contain the size of the pointed-to object.
Where is the size of the pointed-to object stored?
Is it stored at all in the computer?
If it is, I suppose that the information takes up 4 bytes somewhere at a location different from that of the pointer?
Thanks