In addition to what Mattias has said,
the following works pretty well:
Program StrTest;
Var a:Pchar;
Begin
a:=PChar(nil);
Reallocmem(a,20); //ko
a[0] := 'A';
a[1] := 'n';
a[2] := 't';
a[3] := Chr(0);
WriteLn('Done: ', a);
End.
Anton
___
fpc-pascal mail
On Wed, 11 May 2011 08:31:02 -0500
Luis Fernando Del Aguila Mejía wrote:
> Hi, I have two questions about PChar.
>
> Why Reallocmem function does not work with PChar?
> How to increase the size of PChar without using Strings unit?
>
> Thanks.
>
> {$codepage utf8}
> Var a:Pchar;
> i:byte;
>
Hi, I have two questions about PChar.
Why Reallocmem function does not work with PChar?
How to increase the size of PChar without using Strings unit?
Thanks.
{$codepage utf8}
Var a:Pchar;
i:byte;
Begin
ReturnNilIfGrowHeapFails:=true;
a:='x';
for i:=0 to 9 do Writeln('[',i,']',a[i]);