// auto.cpp -- illustrating scope of automatic variables
#include <iostream>
using namespace std;
void oil(int x);
int main()
{
// NOTE: some implementations require that you type cast the
// addresses in this program to type unsigned

    int texas = 31;
    int year = 1999;
    cout << "In main(), texas = " << texas << ", &texas =";
    cout << &texas << "\n";
    cout << "In main(), year = " << year << ", &year =";
    cout << &year << "\n";
    oil(texas);
    cout << "In main(), texas = " << texas << ", &texas =";
    cout << &texas << "\n";
    cout << "In main(), year = " << year << ", &year =";
    cout << &year << "\n";
    return 0;
}

void oil(int x)
{
    int texas = 5;

    cout << "In oil(), texas = " << texas << ", &texas =";
    cout << &texas << "\n";
    cout << "In oil(), x = " << x << ", &x =";
    cout << &x << "\n";
    {                                       // start a block
        int texas = 113;
        cout << "In block, texas = " << texas;
        cout << ", &texas = " << &texas << "\n";
                cout << "In block, x = " << x << ", &x =";
        cout << &x << "\n";
    }                                       // end a block
    cout << "Post-block texas = " << texas;
    cout << ", &texas = " << &texas << "\n";
}

