TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: NEIL HELLER
from: THOMAS MAEDER
date: 1997-08-11 23:45:00
subject: PRINTING POINTER VALUES

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)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.