home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / pascal / 6839 < prev    next >
Encoding:
Internet Message Format  |  1992-11-23  |  1.5 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!nott!cunews!revcan!software.mitel.com!kim!kim
  2. From: kim@Software.Mitel.COM (Kim Letkeman)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: Pointer problems...
  5. Message-ID: <KIM.92Nov23091623@kim.Software.Mitel.COM>
  6. Date: 23 Nov 92 14:16:23 GMT
  7. References: <1992Nov21.181025.18275@jupiter.sun.csd.unb.ca>
  8. Sender: kim@Software.Mitel.COM
  9. Organization: MITEL Public Switching, Kanata, Ontario, Canada
  10. Lines: 40
  11. In-reply-to: tcsmith@mta.ca's message of 21 Nov 92 18:10:25 GMT
  12.  
  13. In article <1992Nov21.181025.18275@jupiter.sun.csd.unb.ca> tcsmith@mta.ca (Tim Smith) writes:
  14.  
  15. |   I wonder if someone could please explain why these pointer operations don't work...
  16. | {*****problem 1**********************}
  17. | var
  18. |   p1: ^byte;
  19. |   p2: ^byte;
  20. |   p3   : pointer;
  21. | begin
  22. |   getmem(p3,100);
  23. |   p1:=P3;
  24. |   p2:=addr(p1);
  25. |   writeln(p1^,' ',p2^,' ');
  26. |           ^^^-----^^^ Why won't these two values be equal?
  27.  
  28. p1 is the same as the contents of p3, which is the address of the
  29. chunk of RAM returned by the getmem call. p2 is the address of p1, not
  30. the _contents_ of p1. So, you should get the value of the first byte
  31. of the chunk of RAM at p3, followed by the value of the first byte of
  32. the address p1, which is actually the lowest order byte of the
  33. address.
  34.  
  35. |   freemem(p3,100);
  36. | end.
  37. | {*****problem 2**********************}
  38. | var
  39. |   P1 : ^Byte;
  40. |   P2 : ^Byte;
  41. | begin
  42. |   new(p1);
  43. |   p2:=p1;   { Why is this illegal }
  44.  
  45. Compiles fine for me.
  46.  
  47. |   dispose(p1);
  48. | end.
  49. --
  50. Kim Letkeman    kim@Software.Mitel.COM
  51.