The data of the file stream in Delphi is written to the dynamic array.

xiaoxiao2021-03-05  50

varmyfile: TfileStream; mybuf: array of Pchar; beginmyfile: = TfileStream.Create ( 'd: /a.txt',fmOpenReadWrite); setlength (mybuf, myfile.size); myfile.ReadBuffer (mybuf [0], myfile.Size ); // delete (String (mybuf), 1, myfile.size-4); showMessage (pchar (mybuf);

This code is also engaged in exploration, not very understanding, it is like this, because the static array in delphi is allocated before running, so its variable address is the first dimension address of this array, That is, the part is not described, so its sizeOf is 1 byte, and the dynamic array is dynamically assigned a memory block during operation, so its variable address section requires a division, so its sizeof is four bytes. Used to store depict tables, in Readput, the first dimension of this array needs to be used as the start address, and it will not result in overflow, and I don't know if this is correct. It is better to understand it. To understanding

转载请注明原文地址:https://www.9cbs.com/read-32903.html

New Post(0)