NH> NH> char * aPtr = &aStr[5];
NH> NH> cout << aPtr << endl;
NH> DM> You want:
NH> DM> cout << (void*)aPtr << endl;
NH> Just an honest question: why, after aPtr was declared to be a point
NH> to char, would you need to cast it in order to print the address
NH> (contents of the pointer).
Because a pointer to character is interpreted as a (pointer to the
first character of a) zero-terminated string.
NH> Instead of a C-style cast, would it be preferred in that situation t
NH> do:
NH> cout aPtr << end;
Yes, I'd use a cast keyword, but like this:
cout (aPtr) << endl;
Thomas
---
þ MM 1.0 #0113 þ Remember when air was clean and sex was dirty?
---------------
* Origin: McMeier & Son BBS (2:301/138)
|