C++ Pointer References both array and pointer using subscripts
#include <iostream> using namespace std; void main()/*from w w w. ja v a 2s.co m*/ { float ara[] = {100.0, 200.0, 300.0, 400.0, 500.0}; float *fptr; // Make pointer point to array's first value. fptr = &ara[0]; cout << *fptr << "\n"; fptr++; cout << *fptr << "\n"; fptr++; cout << *fptr << "\n"; fptr++; cout << *fptr << "\n"; fptr++; cout << *fptr << "\n"; fptr = ara; cout << *(fptr+2) << "\n"; cout << (fptr+0)[0] << " " << (ara+0)[0] << "\n"; cout << (fptr+1)[0] << " " << (ara+1)[0] << "\n"; cout << (fptr+4)[0] << " " << (ara+4)[0] << "\n"; return; }