/**
PPP2-18ex9: Consider the memory layout in §17.4.
Write a program that tells the order in which static
storage, the stack, and the free store are laid out
in memory. In which direction does the stack grow:
upward toward higher addresses or downward toward
lower addresses? In an array on the free store,
are elements with higher indices allocated at higher
or lower addresses?
*/

#include<iostream>
using namespace std;

void* address(void* vs) {
    cout << vs;
}

int main() {
    char* pc = new char[10];
    for(int i = 0; i < 10; ++i) {
        cout << "\nThe address of pc[" << i << "] = ";
        address(pc++);
    }
    double ca[10]={1,2,3,4,5,6,7,8,9,10};
    cout << endl;
    for(int i = 0; i < 10; ++i) {
        cout << "\nThe address of ca[" << i << "] = " << &ca[i];
        //address(&ca[i]);
    }

}
