// ptr5.cpp By: Aiman Hanna - ©1993-2006 Aiman Hanna // This program gives more information on how pointers and array are related. #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; p = a; cout << "This is the array output ... before modifications: \n"; for ( int i = 0 ; i < 5 ; i++ ) cout << a[i] <<"\n"; *(p+3) = 80; *p = 10; cout << "\nThis is the array output ... after modifications: \n"; for ( i = 0 ; i < 5 ; i++ ) cout << a[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: This is the array output ... before modifications: 19 23 7 34 12 This is the array output ... after modifications: 10 23 7 80 12 */