On 04/01/2017 02:33 PM, Jürgen Hestermann wrote:
Am 2017-04-01 um 19:42 schrieb wkitt...@windstream.net:
consider this: when using a string var and writing to a binary file...
you reuse the string var for each value written...
if you don't clear the string var between fills then the binary will
contain "garbage" in the unused positions of the string var...
you can see this "garbage" when you view the binary file in hex mode...
the "garbage" being older longer string data than the current string data in
the var...
this var may be a global throwaway string var...

This can only happen for older string types where the actual length
can differ from the reserved memory (maximum string length).
With managed strings, this should never be possible as it would write
only the bytes of the current length.

some situations call for fixed length records... this same "garbage" effect will be seen in them...

I also don't see how this applies to an array of integers.

it may not... the subject doesn't differentiate... it only says "array" so i provided an example to your query about why this clearing may be desired... i just happened to use an array of char that we loving know as string[255]...


--
 NOTE: No off-list assistance is given without prior approval.
       *Please keep mailing list traffic on the list* unless
       private contact is specifically requested and granted.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to