TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: NEIL HELLER
from: ANTHONY TIBBS
date: 1997-08-10 23:02:00
subject: Re: Printing pointer val

 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?
 Using Turbo C++ 3.00, and the following code, it compiles and runs 
 fine (and prints "fgh" on the screen):
 
 
 
 #include 
 
 int main (void)
 {
 char Str [10] = "abcdefgh";
 char *Ptr = &Str[5];
 
   cout << Ptr << endl;
   return 0;
 }
 
Sincerely,
Anthony Tibbs
... Back up my hard disk? I can't find the reverse switch!
___ Blue Wave/DOS v2.30 [NR]
--- Maximus 3.01
---------------
* Origin: World of Power BBS * Private * Ottawa, ON (1:163/215.38)

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