xxxxxxxxxx
#include <iostream>
using namespace std;
int main()
{
int x[3] = { 5,9,20 };
int* p = x;
cout << p << endl; //prints the address of x[0]
cout << *p << endl; //prints the value of x[0] (5)
//printing the array
for (int i = 0; i < 3; i++){
cout << p[i] << endl;
//or
cout << *(p + i) << endl;
}
}
xxxxxxxxxx
void func( int* pointer){
int i = 0 ;
std::cout << *(pointer+i) ; // list[i]
};
int list[]={1,2,3,9};
int* pointer = list ;
func(pointer);
xxxxxxxxxx
int *ptr;
int arr[5];
// store the address of the first
// element of arr in ptr
ptr = arr;