Board index » delphi » weird pointer behaviour

weird pointer behaviour

I found a seemingly strange property of pointers.  That is, I had a
pointer to an array, CrossedOff.  I passed this pointer to a procedure
as a value parameter, but none of the changes I made to the ARRAY- that
is, CrossedOff^- remained.  However, when I changed the pointer to a
variable parameter, everything was just ducky.

        Now, my question is, if the pointer is simply pointing to
an address in memory, should not a COPY of that pointer (ie a value
parameter) point to EXACTLY the same spot in memory?  And, therefore,
should not any changes made to what is being pointed at remain
regardless of value or variable status?

        If I'm being really confusing I can supply code, but I'm sure
there's a very simple answer to my question.

Evan

 

Re:weird pointer behaviour


In article <60c5ao$qi...@canopus.cc.umanitoba.ca> of Wed, 24 Sep 1997
17:46:39 in comp.lang.pascal.misc, Evan Falk <evan**REMOVE@THIS**mindles

Quote
s.com> wrote:
>I found a seemingly strange property of pointers.  That is, I had a
>pointer to an array, CrossedOff.  I passed this pointer to a procedure
>as a value parameter, but none of the changes I made to the ARRAY- that
>is, CrossedOff^- remained.  However, when I changed the pointer to a
>variable parameter, everything was just ducky.
> ...

This is comp.lang.pascal.misc; it deals with all Pascal systems, though
other groups are better for specific compilers.  Yours would seem to be
a compiler-specific problem, or at least possibly so; you give no
details of your system, and no code fragment.  Greater skill than mine
will therefore be needed to elucidate your difficilty.

--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web URL: http://www.merlyn.demon.co.uk/ - FAQqish topics, acronyms and links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Before a reply, quote with ">" / "> ", known to good news readers (SoRFC1036)

Re:weird pointer behaviour


Quote
Evan Falk wrote:
> I found a seemingly strange property of pointers.  That is, I had a
> pointer to an array, CrossedOff.  I passed this pointer to a procedure

> as a value parameter, but none of the changes I made to the ARRAY-
> that
> is, CrossedOff^- remained.  However, when I changed the pointer to a
> variable parameter, everything was just ducky.

     That certainly SHOULD work.  I pass pointers all the time as value
parameters, use
them to walk down lists and change things as needed.  Are you sure you
are passing the
pointer, and not the "thing pointed to" (the array, in your case)?

Bob Schor
Pascal Enthusiast

Other Threads