C++ Array Access array subscripts with pointers
#include <iostream> using namespace std; int main()/* www . j a va 2 s . com*/ { const int ARRAYSIZE = 5; int *gPtr; // declare a pointer to an int int i, grade[ARRAYSIZE] = {98, 87, 92, 79, 85}; gPtr = &grade[0]; // store the starting array address for (i = 0; i < ARRAYSIZE; i++) cout << "\nElement " << i << " is " << *(gPtr + i); cout << endl; return 0; }