delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/15/08:15:24

From: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: & and cout... print's "1"...
Date: Tue, 14 Oct 1997 08:43:19 +0200
Organization: Lehrstuhl fuer Stroemungsmechanik
Lines: 51
Message-ID: <34431487.92C4023F@LSTM.Ruhr-UNI-Bochum.De>
References: <19971013225101 DOT SAA14664 AT ladder01 DOT news DOT aol DOT com>
NNTP-Posting-Host: c64.lstm.ruhr-uni-bochum.de
Mime-Version: 1.0
CC: Egg brains <eggbrains AT aol DOT com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Egg brains wrote:
> 
> okay, i hate to ask question in here... (it's only rarely that i can ever
>  answer questions and there fore i feel like someones pulling me around)
> 
> anyway, i got stuck (for the last 2 days now)
> 
> when i try:
> 
> long foo;
> foo=800;
> cout << &foo;
> 
> it only print's "1"... how come? shouldn't it print the referenec of foo? and
>  when i try to put it in a varible first such as

That's a bug in the iostream library. Search the mail archive for a 
recent discussion. Or even better, port the new version to DJGPP
(just kidding)
The workaround is what you did below, maybe with a leading 
<< hex()
before the variable. 

> 
> long foo;
> foo=800;
> long stuck=(long)&foo;
> cout << stuck;
> 
> it prints a number other than one, but when i run the program again and again,
>  the number stay's the same. when i swtich around the loading order for the
>  varible the number stays the same as well..
Probably it's a local var, so the location on the stack should remain
the same within runs. Even if it were global, depending on your system 
environment, it is pretty likely to occupy always the same location
in memory. So this is not worrying. 

-- 
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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019