I think you could just manage the end of your string with a #0 char.

Just allocate enough space for the maximum size of your string plus the terminal #0 char.

For example

program Project1;
{$mode objfpc}{$H+}
uses
  SysUtils, Classes;
var
   s: array[0..30] of char;
   p: PChar;
begin
     p:= @s;
     StrPLCopy( p, 'Test', 30);
     Writeln( p);
     s[3]:= #0;
     Writeln( p);
end.

produces

$ ./project1
Test
Tes
$
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to