I will attach the code snippet below:
#include <bits/stdc++.h>
using namespace std;
int main()
{
// typecasting pointers
int x = 97;
int *p1 = &x;
char *p0 = (char *)p1;
cout << *p1 << " " << *p0 << "\n";
cout << p1 << " " << p0 << "\n";
}
The output to this code is:
97 a
0x70fe04 a
The first line is understandable. But shouldnt second line be 0x70fe04 0x70fe04 ? Why does p0 print the value at the address 0x70fe04 and not the address itself?
Expected output:
97 a
0x70fe04 0x70fe04