//----------------------------------------------------------------- // // pointers0.cpp // // Using a pointer to handle the members of an array. // // written by: Elizabeth Sklar, modified by Simon Parsons // modified : 25th April 2009 // //----------------------------------------------------------------- #include using namespace std; int main() { int i, *j, arr[5]; for ( i=0; i<5; i++ ) { arr[i] = i; } cout << "C++: arr=" << arr << endl; cout << endl; for ( i=0; i<5; i++ ) { cout << "i=" << i; cout << " arr[i]=" << arr[i]; cout << " &arr[i]=" << &arr[i]; cout << endl; } cout << endl; j = &arr[0]; cout << "j=" << j; cout << " *j=" << *j; cout << endl << endl;; j++; cout << "after adding 1 to j: j=" << j; cout << " *j=" << *j << endl; }