I am trying to learn the concept of pointers in depth. In the below code , I create an array an create a pointer to each of the element.
int bucky[5];
int *bp0 = &bucky[0];
int *bp1 = &bucky[1];
int *bp2 = &bucky[2];
cout<<"bp0 is at memory address:"<<bp0<<endl;
cout<<"bp1 is at memory address:"<<bp1<<endl;
cout<<"bp2 is at memory address:"<<bp2<<endl;
These are the memory allocations given to the array elements.
bp0 is at memory address:0x0018ff3c
bp1 is at memory address:0x0018ff40
bp2 is at memory address:0x0018ff44
With my limited knowledge in c++ , I am aware that memory is allocated contiguously to an array. But looking at the output closely, bp0 looks out of place.
According to me bp0 should be at 0x0018ff36. Or is it that the locations 0x0018ff3c , 0x0018ff40 , 0x0018ff44 are continuous in the CPU?
So is it possible that two contiguous memory allocations are not assigned in a progression?