C++ examples for Data Type:Array Pointer
Access array subscripts with pointers
#include <iostream> using namespace std; int main()// www . j a v a 2 s. c o m { 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; }