Say you know a memory location address (say 0x22ff70) and you want to know what is stored there (if anything), how do you go about printing the contents on screen?
C++ Pointers?
Casting, that is the magic of C++.
Try these articles.
http://www.boost.org/libs/conversion/cas...
http://en.wikipedia.org/wiki/Pointer
http://www.informit.com/guides/content.a...
Good luck
Reply:U can store this address in a pointer. Get the value thro' *
I think its correct. I studied this long back. Sorry if am wrong
Reply:If you want to print the valud of a variable you "Printf("%i",varr). (For example)
If its a pointer you have to "Printff("%i";%26amp;point). You have to tell the printing function to print not the value of the pointer (0x22ff70 in this case) but the value of the address the pointer points :).
Reply:If you know exactly data type kept at this address, do the following:
...
known_data_type * ptr = (known_data_type) void_pointer;
// print your known data here...
...
In another case, you cah just cast this address to char* or unsigned char * and get some dump:
...
unsigned char * up = (unsigned char *) void_pointer;
dump( up, any_size_you_need_if you_know_it);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment