🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3445

Re: Displaying addresses of variables in hex?

#3445
From: Oleg Krivosheev
Date: Sun, 17 Nov 1996 00:00
37 lines
1310 bytes

Hi,

Borg <vladimip@iceonline.com*> writes:

> 
> Hi,
> 
> A quick (dumb?) question:
> 
> How do I display variable addresses in hex rather than in decimal?
> An example:
> 
>   double var;
>   cout << "var value is " << var << " and its address is ";
>   cout << unsigned (&var) << endl;
> 
> A sample output:
> 
> [vlad@borg pointers]$ address
> var value is 6 and its address is 3221223436.
> 
> My (platform/OS independent) books insist on using:
> 
> cout << &var << endl; (without "unsigned" and without 
> round brackets!) I am using gcc/g++ 2.7.2 on Linux-i586.
> 
> Please reply in newsgroups.

i don't know is this bug or not, but in order to
get address printed, you have to explicitely cast it to
(void*).

cheers

OK
Technical Details
Message-ID: <vi83ey83ywj.fsf@thor.fnal.gov>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <56m5ch$noi@news.iceonline.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc89c,7ec25c815d4734dc
X-Google-Attributes: gidfc89c,public
X-Google-Thread: 10ba33,7ec25c815d4734dc
X-Google-Attributes: gid10ba33,public
From: Oleg Krivosheev <kriol@fnal.gov>
Subject: Re: Displaying addresses of variables in hex?
Date: 1996/11/17
Message-ID: <vi83ey83ywj.fsf@thor.fnal.gov>
X-Deja-AN: 197134943
sender: kriol@thor.fnal.gov
references: <56m5ch$noi@news.iceonline.com>
organization: FERMILAB, Batavia, IL
newsgroups: comp.unix.programmer,gnu.g++.help