From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: Please help the newbie! Date: Thu, 25 Sep 1997 20:45:24 +0200 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 45 Message-ID: <342AB144.460A94BD@LSTM.Ruhr-UNI-Bochum.De> References: <875153762 DOT 25454 AT dejanews DOT com> <60cpl7$2pk AT sjx-ixn3 DOT ix DOT netcom DOT com> <875206466 DOT 2246 AT dejanews DOT com> NNTP-Posting-Host: c64.lstm.ruhr-uni-bochum.de 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 joe DOT charles AT mail DOT sprintranet DOT com wrote: [...] > > > int temp=5; > > > cout << "Address: " << &temp > > > > > Now, when I compile this and run it, I get "Address: 1" instead of the > > > actual memory address of the temp variable. > > > > If the method above is the only way you know to show the address of a > > variable, how do you know the output is wrong? Were you expecting to see > > '5'? If you were, you apparently don't understand the underlying concept, > > and I'd recommend rereading your material more carefully. > > What I was expecting to see was something like "0x8fc9:fff2" for example. > What is the underlying concept you are referring to? I will admit I am > relatively new to this, but it seems fairly straightforward to want to > view the memory address of a variable. As you say, "1" could very well > be the address, but I tried the above example with 3 different variables, > expecting to see their addresses listed sequentially 2 bytes apart (short > int on my machine). Instead, it gave me "1, 1, 1" which seems incorrect > to me. In fact it is. What you should see is something like 0xdeadbeef or so. I think this is a bug in the iostream library. Another reason for porting a newer version to DJGPP... If I should have the time I'll look at it, but I doubt that... Any other volunteers? -- Ciao Tom ************************************************************* * Thomas Demmer * * Lehrstuhl fuer Stroemungsmechanik * * Ruhr-Uni-Bochum * * Universitaetsstr. 150 * * D-44780 Bochum * * Tel: +49 234 700 6434 * * Fax: +49 234 709 4162 * * http://www.lstm.ruhr-uni-bochum.de/~demmer * *************************************************************