#include<iostream> using namespace std; int main(){ int a=12; char *p; p =(char*)&a; *p='a'; cout<<(char*)(&a); cout<<&a; cout<<*(&a); return 0; }
& A is a return address (may also be called a pointer) and a pointer type of the data type to be consistent with the extracted value must tell the computer to use this is an address to fetch the address value * (& a) corresponding to the address for fetching the value of the memory address
p = & a ; if such assignment would directly above error: This is because & a return address is the integer p is indeed character data address pointer should convert an integer to a character pointer which will herein as char address of the data to find the relevant addresses the reader can be observed above
cout<<(char*)(&a);和
<< * COUT (& A );
the result is not the same
error: cannot convert ‘int*’ to ‘char*’ in assignment p=&a;