Mail Archives: djgpp/1997/09/27/02:15:20
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 *
*************************************************************
- Raw text -