Hi,
I encountered unpredictable behavior with the following code:
var
fs: TFileStream;
s: string;
begin
... ...
fs.Write(s, Length(s));
... ...
end;But if I do this, then problem is gone:
var
fs: TFileStream;
s: string;
buf: PChar;
begin
... ...
buf := GetMem(Length(s) + 1);
StrPCopy(buf, s);
fs.Write(buf^, Length(s));
... ...
end;My question is, why the above code with string works sometime, but not alwasy fail? What is the internal structure of string and variable array (i.e. array of something)? What is the difference between @string and @string[1] or @array and @array[0]?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130303/a749fca3/attachment.html>
