Talk:Dynamic array

From Lazarus wiki
Revision as of 20:13, 10 August 2014 by Ruediger (talk | contribs) (FillChar / SizeOf)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

I was a little bit confused about the sentence "To init such an invalid pointer you have to use FillChar(MyVariable,sizeof(MyVariable), #0)." This might be misleading, as this fills the pointer to MyVariable with the size of this pointer with zeros, not the array itself, as far as I anderstand. This might be different to static arrays (didn't prove that).

Anyway: It took me some time to find out, how to initialize the array itself: FillChar(MyVariable[0], Length(MyVariable) * SizeOf(TheArrayType), #0);

Perhaps this difference between initializing the array itself and the reference to the array should be emphasized? Or did I misunderstand something there?