TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: NEIL HELLER
from: DARIN MCBRIDE
date: 1997-08-09 12:49:00
subject: Printing pointer values

 -=> Quoting Neil Heller to All
 NH> Given the following code:
 NH> char aStr[10] = "abcdefgh";
 NH> char * aPtr = &aStr[5];
 NH> cout << aPtr << endl;
 NH> The output is garbage.  How does one correct print the value of a
 NH> pointer?
The output shouldn't be garbage - it should be "fgh"!
That it isn't what you _want_ to output isn't an issue - it isn't garbage,
just not the desired output.
You want:
cout << (void*)aPtr << endl;
... "You cannot change a person with your fists . . ." -Bruce Lee
--- FastEcho 1.46
---------------
* Origin: House of Fire BBS - Toronto - (416)601-0085 - v.34 (1:250/536)

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™.