| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: Printing pointer valu |
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? To print the _value_of_the_pointer_, cast the pointer to a void* cout << (void*)aPtr; //generates something like 0x5423:3212 But I don't understand why your code prints "garbage". It ought to output: fgh --- þ Blue Wave/QWK v2.12 þ ---------------* Origin: St. Louis Users Group (1:100/4) |
|
| 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™.