delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/28/23:33:22

From: "Thomas Jansen" <jansen AT cs DOT bonn DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Please help the newbie!
Date: 27 Sep 1997 11:52:02 GMT
Organization: NDH Netzwerkdienste Hoeger
Lines: 22
Message-ID: <01bccabd$8f5567e0$LocalHost@default>
References: <875153762 DOT 25454 AT dejanews DOT com>
NNTP-Posting-Host: port100.koeln.ndh.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

> 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.
> 
> Does DJGPP not support the & operator?  How can I see the address of a
> given variable?

try

cout << int(&temp) << endl;

or

cout << hex << int(&temp) << endl;

and it will work.. otherwise djgpp uderstand the pointer as a char* (this
is the only known pointer)...

greets, thomas...

- Raw text -


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