i create an Array with 3 numbers; i see only one number instead 3
int *ArrayA;
ArrayA = new int[3];
ArrayA[0] = 2;
ArrayA[1] = 4;
ArrayA[2] = 6;
when i debugging and follows ArrayA i see only 2; what could be the problem?
i create an Array with 3 numbers; i see only one number instead 3
int *ArrayA;
ArrayA = new int[3];
ArrayA[0] = 2;
ArrayA[1] = 4;
ArrayA[2] = 6;
when i debugging and follows ArrayA i see only 2; what could be the problem?
Your object ArrayA is of type int *. Hence it points to a single int. The fact that you have it point at an int[3] array doesn't change that fact. Your debugger can also not guess that you want it to display more than one value.
Instead of using raw c-style arrays, it is usually recommended to use an std::array.
std::array<int,3> arrayA = {2,4,6};
This is not a problem. It's as expected because ArrayA is a pointer. So pointer base address and the address of the 1st element of the array are same. Hence you always see 2 in your debugger. Not sure which debugger you are using, you can try to add ArrayA[index] or *(ArrayA + index) then you can see other values as well.