Date: Thu, 22 May 1997 17:52:02 -0600 From: lenny AT netvision DOT net DOT il Subject: Re: Can't print address using cout Newsgroups: comp.os.msdos.djgpp Message-ID: <864340913.7033@dejanews.com> Reply-To: lenny AT netvision DOT net DOT il Organization: Deja News Usenet Posting Service References: <337F611D DOT 4FCE AT netvision DOT net DOT il> <3380C376 DOT 6F173422 AT alcyone DOT com> Lines: 55 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Erik, Thanks for your help. The cast (void *) did the trick. However, isn't it strange that the djgpp compiler lacks such a basic function that would give it the ability to print out memory addresses (i.e. no member function ostream::operator <<(long *))? Thanks again, Lenny Stendig lenny AT netvision DOT net DOT il 32.87°N · 35.08°E P.S. In case you're still into the geographic wonder of the Net, you just helped someone sitting half way around the world solve his compiler problem (I'm in Haifa, Israel and you're in CA). In article <3380C376 DOT 6F173422 AT alcyone DOT com>, Erik Max Francis wrote: > > 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 -------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to Usenet