// dynarray_02.cpp - pointer arithmetic
#include <iostream>
int main()
{
    using namespace std;

    // delcaring an integer array with 3 elements, and initializing them
    int students[3] = {13, 8, 21};

    int * p_st = students;     // name of an array = address

    // printing out the pointer value (address) and dereferenced pointer (val)
    cout << "p_st = " << p_st << ", *p_st = " << *p_st << endl;
    
    // incrementing pointer
    p_st = p_st  + 1;
    
    // print out new values
    cout << "add 1 to the p_st pointer:\n";
    cout << "p_st = " << p_st << ", *p_st = " << *p_st << "\n\n";

    // setting the pointer to address of first element of the array
    p_st = &students[0];

    // showing two differen ways of referencing array values
    cout << "access two elements with array notation\n";
    cout << "students[0] = " << students[0] 
         << ", students[1] = " << students[1] << endl;
    cout << "access two elements with pointer notation\n";
    cout << "*p_st = " << *p_st
         << ", *(p_st + 1) =  " << *(p_st + 1) << endl;

    // printing out sizes
    cout << sizeof(students) << " = size of students array\n";
    cout << sizeof(p_st) << " = size of p_st pointer\n";
}

