From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: Can't print address using cout Date: Mon, 19 May 1997 14:17:42 -0700 Organization: Alcyone Systems Lines: 30 Message-ID: <3380C376.6F173422@alcyone.com> References: <337F611D DOT 4FCE AT netvision DOT net DOT il> NNTP-Posting-Host: newton.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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