void func( int* pointer){
int i = 0 ;
std::cout << *(pointer+i) ; // list[i]
};
int list[]={1,2,3,9};
int* pointer = list ;
func(pointer);
#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;
}
}
int *ptr;
int arr[5];
// store the address of the first
// element of arr in ptr
ptr = arr;
#include<stdio.h>
int main()
{
int arr[5] = {10, 20, 30, 40, 50}, i;
for(i = 0; i < 5; i++)
printf("value stored in arr[%d] = %d
",i,*(arr+i));
return 0;
}
#include<stdio.h>
int main()
{
int arr[5] = {10, 20, 30, 40, 50}, i;
for(i = 0; i < 5; i++)
printf("Address of arr[%d] = %p
",i,arr+i);
return 0;
}