C++ examples for Data Type:Array Pointer
Use pointer notation and reference pointers as arrays with array notation.
#include <iostream> using namespace std; void main()/*w w w . j a v a 2 s . c o 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; }