I have trouble in understanding the difference between the two: (int *) (&a[2]) and *(&a[2]). I understand &a[2] gets the address of a[2] and *gets the value in that address, so *(&a[2]) get the value of a[2], which is 3. But how come (int *)(&a[2]) returns an address? Thank you!
Output:
3
0x7fff40144888
Codes:
include<iostream>
using namespace std;
int main()
{
int a[3]={1,2,3};
//cout << *(a+2) << endl;
cout << *(&a[2]) << endl;
cout << (int*)(&a[2]) << endl;
}