www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/26/15:16:57

Date: Thu, 25 Sep 1997 12:02:38 -0600
From: joe DOT charles AT hermes DOT sprintranet DOT com
Subject: Re: Please help the newbie!
Newsgroups: comp.os.msdos.djgpp
Message-ID: <875206466.2246@dejanews.com>
Organization: Deja News Posting Service
References: <875153762 DOT 25454 AT dejanews DOT com> <60cpl7$2pk AT sjx-ixn3 DOT ix DOT netcom DOT com>
Lines: 33
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <60cpl7$2pk AT sjx-ixn3 DOT ix DOT netcom DOT com>,
  firewind <firewind AT metroid DOT dyn DOT ml DOT org> wrote:

> 21 days? To learn C++? Surely this is a joke.

Well, we all have to start somewhere, eh?  Thanks for the support.

>
> > Day 8 discusses pointers, and says you can use the "&" operator to see the
> > particular address of any given variable, as in:
>
> > 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.
>
> If the method above is the only way you know to show the address of a
> variable, how do you know the output is wrong? Were you expecting to see
> '5'? If you were, you apparently don't understand the underlying concept,
> and I'd recommend rereading your material more carefully.

What I was expecting to see was something like "0x8fc9:fff2" for example.
 What is the underlying concept you are referring to?  I will admit I am
relatively new to this, but it seems fairly straightforward to want to
view the memory address of a variable.	As you say, "1" could very well
be the address, but I tried the above example with 3 different variables,
expecting to see their addresses listed sequentially 2 bytes apart (short
int on my machine).  Instead, it gave me "1, 1, 1" which seems incorrect
to me.

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet

- Raw text -


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