// ptr6.cpp By: Aiman Hanna - ©1993-2006 Aiman Hanna // This program gives more information on pointers, and how they can be manipulated. #include int main() { int a[5]; a[0] = 19; a[1] = 23; a[2] = 7; a[3] = 34; a[4] = 12; int *p = new int, *q = new int, x = 3; *q = 75; p = a; cout << "\nThis is the array output ... before modifications: \n"; for ( int i = 0 ; i < 5 ; i++ ) cout << a[i] <<"\n"; *p = *q + x; cout << "\nThis is the array output ... after modifications: \n"; for ( i = 0 ; i < 5 ; i++ ) cout << a[i] <<"\n"; q = p; cout << "\nThis is the array output ... using pointer q: \n"; for ( i = 0 ; i < 5 ; i++ ) cout << *(q + i) <<"\n"; return 0; } // The following is the result of compilation // Compilation successful // The following is the result of running the program /* This is the array output ... before modifications: 19 23 7 34 12 This is the array output ... after modifications: 78 23 7 34 12 This is the array output ... using pointer q: 78 23 7 34 12 */