Decrementing a Pointer for int value
#include <iostream>
using namespace std;
const int Length = 3;
int main ()
{
int testScore[Length] = {4, 7, 1};
int* intPointer = &testScore[Length - 1];
int i = Length - 1;
while (intPointer >= &testScore[0])
{
cout << "The address of index " << i
<< " of the array is "<< intPointer << endl;
cout << "The value at index " << i
<< " of the array is "<< *intPointer << endl;
intPointer--;
i--;
}
return 0;
}
Related examples in the same category