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)
|