I am learning C++ and have become a little confused to how a Pointer to an Integer Value and a Pointer to an Array differ... See my code below:
int main(void)
{
int* ptrOne;
int VarOne = 25;
ptrOne = VarOne;
int* ptrTwo;
int ArrayTwo[6];
ArrayTwo[0] = 2; //ect for the rest of the array, omitted here.
ptrTwo = ArrayTwo;
}
Pointers are just variables that hold an address.
For the line ptrOne = VarOne, it shoves the VALUE of 25 into ptrOne.
For the line ptrTwo = ArrayTwo, it shoves the ADDRESS of ArrayTwo[0] into ptrTwo.
Why is ptrTwo = ArrayTwo equivalent to ptrTwo = &ArrayTwo[0], but ptrOne = VarOne is NOT equal to ptrOne = &VarOne?
Is this due to the fact the operation is happening to an array vs an int?
Thanks in advance for any help, I have stepping through this code in my compiler and looked at the addresses in memory and the associated values, I did also read the answer for how to differentiate integer pointer and integer array pointer, but it did not fully explain the differences.