Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!petunia!news From: mdella@polyslo.CalPoly.EDU (Marcos R. Della) Newsgroups: comp.lang.pascal Subject: Re: Pointers in TP Keywords: Pointers, TP Message-ID: <27fc2345.5f49@petunia.CalPoly.EDU> Date: 5 Apr 91 07:12:05 GMT References: <5841@gara.une.oz.au> Organization: Cal Poly State Univ,CSC Dept,San Luis Obispo,CA 93407 Lines: 42 In article <5841@gara.une.oz.au> ijohnson@gara.une.oz.au (Ian Johnson) writes: > and then in the program have the statement > SingleCol := A^[25].col^; > ...is, is this safe? I'm not really experienced with pointers, and am > worried that it may appear to work, but that the memory associated with > SingleCol may be over written. The thing that you are doing in the above statment is taking the VALUE of the memory location pointed to by A^[25].col^ and storing that into the storage location of the SingleCol variable. The problem you get with pointers starting to do strange things (at least what I think your worried about) is when you start assigning pointers to pointers to get a value... ie. VAR a,b : ^integer; a^ := 5; b := a; the value of b^ is now going to be 5. If I set (a^ := 8) then b^ will magically change to the value of 8 insted of the previous 5. The reason is that the pointer to the memory locations are the same. So when you change the 5 in memory with the a^ you get the same effect with the b^. If a and b are different pointers, then b^ := a^ is safe from the above manipulation... There are a bunch to things to worry about pointers... Just experiment. Don't worry, you'll get lost, pull out your hair and wonder where all your numbers went to and why Null values are appearing... Its all part of the fun... -- ..!csustan ->!polyslo!mdella | mdella@polyslo | Whatever I said doesn't ..!sdsu ---/ Marcos R. Della | (805) 544-4825 | mean diddly as I forgot ..!csun --/ 1663 Phillips Ln. / it even before finishing ..!dmsd -/ San Luis Obispo, CA 93401 / typing it all out!!! :-)