I know that you can use dynamic arrays (array of). Is better.
But this does not understand and confuse me.
Why to create an array of 3 elements (ANSIString) with GetMem, I have to put a size of 15 bytes (5*3) and not 12 bytes (4*3).? The program works with 15 bytes, but do not understand why not work with 12 bytes.
Thanks.

{$codepage utf8}
Var LCad:^ansiString;
Begin
  getmem(LCad,5*3);  //ansistring is a pointer 4 bytes
  LCad[0]:='01234';
  LCad[1]:='56789';
  LCad[2]:='11111';
  Writeln(LCad[2]);
  freemem(LCad)
End.


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to