CD> To print the _value_of_the_pointer_, cast the pointer to a void*
CD> cout << (void*)aPtr; //generates something like 0x5423:3212
NH> It amazes me that after I have declaired aPtr to be a pointer that I
NH> wouldn't have to dereference it if printing it's contents. In light
NH> of that I would think that it would keep outputing characters until (if
NH> you're lucky) it came across a NULL and that byte were still somewhere
NH> legal to print. Is this the only situation that you know of where
NH> such a cast is necessary?
You mean a cast where casting one way gives one result and casting
another way yields a different result??? Hmm... I can't think of
any, but I can think of cases where it could be used, but isn't,
within windows.
There are some functions that have a prototype along the lines
of:
foo (int Action, long MoreInformation);
Depending on Action, MoreInformation could be an integer value, or
it could be a pointer to one or more types of structures. So then,
if MoreInformation was the address of a character string, you would
have to cast the address to a long just to meet the syntax
requirements of the proc call.
---
þ Blue Wave/QWK v2.12 þ
---------------
* Origin: St. Louis Users Group (1:100/4)
|