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
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to