delorie.com/archives/browse.cgi | search |
From: | Weiqi Gao <weiqigao AT a DOT crl DOT com> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Address of Operator |
Date: | Thu, 30 Apr 1998 21:10:56 -0500 |
Organization: | Spectrum Healthcare Services |
Lines: | 29 |
Message-ID: | <35492F30.C7E82CC4@a.crl.com> |
References: | <35491c0d DOT 0 AT lightning DOT ica DOT net> |
NNTP-Posting-Host: | a116004.stl1.as.crl.com |
Mime-Version: | 1.0 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
aalfonso wrote: > > I'm trying out a sample program in my C++ book. The program should print the > memory address of a variable to the screen using the address of operator > & . This is a sample; > > unsigned short int myAge = 5; > cout << "myAge: " << myAge << "\n"; > cout << "&myAge: " << &myAge << "\n"; > > this should output: > myAge: 5 > &myAge: 0x355C // or some such address > > I always get this output when I use the & operator in this context. > > myAge: 5 > &myAge: 1 > > Could someone tell me if i'm doing something wrong? Or does Djgpp not > support the & operator in this context? Any help is greatly appreciated. > Alan Try: cout << (void *) &myAge << "\n"; -- Weiqi Gao weiqigao AT a DOT crl DOT com
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |