#include<iostream> using namespace std; int main() { double price[] = {75, 125,188}; short count[] = { 5, 3, 1 }; double *pr = price; short *ct = &count[0]; cout << "pr = " << pr <<" , " << "*pr = " << *pr << "\n"; pr = pr + 1; cout << "now pr = " << pr << " , " <<"*pr = " << *pr <<"\n"; cout << "access two element with array notation\n"; cout << "count[0] = " << count[0] << endl; cout << "count[1] = " << count[1] << endl; cout << "access two element with pointer notation\n"; cout << "*count = " << *count << " , *(count + 1) = " << *(count + 1) << endl; cout <<"size of count is " << sizeof(count) << endl; cout << "size of *ct is " << sizeof(ct) << endl; return 0; }
result:
pr = 0x22fe10 , *pr = 75
now pr = 0x22fe18 , *pr = 125
access two element with array notation
count[0] = 5
count[1] = 3
access two element with pointer notation
*count = 5 , *(count + 1) = 3
size of count is 6
size of *ct is 8