Mail Archives: djgpp/1997/05/20/03:17:23
Lenny Stendig wrote:
> Output:
>
> &x: 1 &y: 1
>
> I can get an address to appear by using printf. Any ideas as to why
> cout doesn't work? (I'm using DJGPP Version 2.01)
It's because there's no ostream::operator <<(long *) member function, so
when you're trying to print a long * it's getting casted to something else
(though I honestly can't say what offhand).
Instead, you should explicitly cast to void * before sending it to the
ostream:
cout << "&x = " << (void *) &x << "; &y = " << (void *) &y << endl;
Be sure to use cout << endl instead of just sending newlines, as cout is
buffered. You should also be putting an end of line at the end of your
printing, or otherwise it might get covered up by the command prompt,
depending on what you're using.
--
Erik Max Francis, &tSftDotIotE / email / max AT alcyone DOT com
Alcyone Systems / web / http://www.alcyone.com/max/
San Jose, California, United States / icbm / 37 20 07 N 121 53 38 W
\
"The future / is right there."
/ Bill Moyers
- Raw text -