home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!nott!cunews!revcan!software.mitel.com!kim!kim
- From: kim@Software.Mitel.COM (Kim Letkeman)
- Newsgroups: comp.lang.pascal
- Subject: Re: Pointer problems...
- Message-ID: <KIM.92Nov23091623@kim.Software.Mitel.COM>
- Date: 23 Nov 92 14:16:23 GMT
- References: <1992Nov21.181025.18275@jupiter.sun.csd.unb.ca>
- Sender: kim@Software.Mitel.COM
- Organization: MITEL Public Switching, Kanata, Ontario, Canada
- Lines: 40
- In-reply-to: tcsmith@mta.ca's message of 21 Nov 92 18:10:25 GMT
-
- In article <1992Nov21.181025.18275@jupiter.sun.csd.unb.ca> tcsmith@mta.ca (Tim Smith) writes:
-
- | I wonder if someone could please explain why these pointer operations don't work...
- | {*****problem 1**********************}
- | var
- | p1: ^byte;
- | p2: ^byte;
- | p3 : pointer;
- | begin
- | getmem(p3,100);
- | p1:=P3;
- | p2:=addr(p1);
- |
- | writeln(p1^,' ',p2^,' ');
- | ^^^-----^^^ Why won't these two values be equal?
-
- p1 is the same as the contents of p3, which is the address of the
- chunk of RAM returned by the getmem call. p2 is the address of p1, not
- the _contents_ of p1. So, you should get the value of the first byte
- of the chunk of RAM at p3, followed by the value of the first byte of
- the address p1, which is actually the lowest order byte of the
- address.
-
- | freemem(p3,100);
- | end.
- |
- | {*****problem 2**********************}
- | var
- | P1 : ^Byte;
- | P2 : ^Byte;
- | begin
- | new(p1);
- | p2:=p1; { Why is this illegal }
-
- Compiles fine for me.
-
- | dispose(p1);
- | end.
- --
- Kim Letkeman kim@Software.Mitel.COM
-