🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3442

Displaying addresses of variables in hex?

#3442
From: Borg
Date: Sat, 16 Nov 1996 00:00
26 lines
1165 bytes
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.

Thank you in advance,
Vlad
Technical Details
Message-ID: <56m5ch$noi@news.iceonline.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10ba33,7ec25c815d4734dc,start
X-Google-Attributes: gid10ba33,public
X-Google-Thread: fc89c,7ec25c815d4734dc,start
X-Google-Attributes: gidfc89c,public
From: Borg <vladimip@iceonline.com*>
Subject: Displaying addresses of variables in hex?
Date: 1996/11/16
Message-ID: <56m5ch$noi@news.iceonline.com>
X-Deja-AN: 196983778
content-type: text/plain; charset=us-ascii
organization: A carbon+silicon-based life form
mime-version: 1.0
newsgroups: comp.unix.programmer,gnu.g++.help
x-mailer: Mozilla 3.01 (X11; I; Linux 2.0.25 i586)