C++ Pointer notation and reference pointers as arrays with array notation
#include <iostream> using namespace std; void main()//from www. j a v a 2s. co m { int ctr; int iara[5] = {10, 20, 30, 40, 50}; int *iptr; iptr = iara; cout << "Using array subscripts:\n"; cout << "iara\tiptr\n"; for (ctr=0; ctr<5; ctr++) { cout << iara[ctr] << "\t" << iptr[ctr] << "\n"; } cout << "\nUsing pointer notation:\n"; cout << "iara\tiptr\n"; for (ctr=0; ctr<5; ctr++) { cout << *(iara+ctr) << "\t" << *(iptr+ctr) << "\n"; } return; }