Pointers store memory addresses:
int val = 42;
int *p = &val;
Dereference operator recover objects:
std::cout << *p << std::endl;
42
Say that the val's memory address is:
std::cout << p << std::endl;
0x7fff9b2c9794
If I need read what is in a certain memory address?:
int *memAdd = 0x7fff9b2c9794;
std::cout << *memAdd << std::endl;
Error:
error: invalid conversion from ‘long int’ to ‘int*’ [-fpermissive]
How can I do that?
Aucun commentaire:
Enregistrer un commentaire