I am attempting to implement a buddy memory system using c++, but I am running into some issues. I assign a memory address to an element in an array, and the memory address that is stored in main is different than the one returned by the function. I believe there is an error when the address is stored, resetting it to a "valid" position, but i'm not sure which one is the "correct" address. Code and input are posted below.