#include <iostream>
usingnamespace std;
void readSizeAndAllocateArray(int ** ptr, int *size, int **maxIdx, int **minIdx)
{
*ptr = newint[*size]; //fill the memory location for the array subscripts
*maxIdx = *(ptr + *size);
*minIdx = *ptr -1;
cout << *maxIdx << endl;
cout << &maxIdx << endl;
cout << maxIdx << endl;
}
int main()
{
int size = 0;
int * sPtr = NULL;
int * minIdx = NULL;
int * maxIdx = NULL;
cout << "Enter the size of the array: ";
cin >> size; //fills the memory location for the size
readSizeAndAllocateArray(&sPtr, &size, &minIdx, &maxIdx); //since you have a pointer to a pointer you need the &
for (int i=0; i<size; i++)
{
sPtr[i] = i;
cout << sPtr[i] << endl;
maxIdx[i] = i;
cout << maxIdx[i] << endl;
}
return 0;
}
the problem is that when I cout the max index all I see is the address of the operator. Can someone show me I am doing wrong? Or "point" me in the write direction
When I take your suggestion of removing the -1 and the *size I still get the address locations. I am doing research to see if I happened to miss anything, and trying to read up on pointers again.