[fpc-pascal] Pchar from constant string
XHajT03 at hajny.biz
Thu Jun 29 16:33:57 CEST 2023
On 2023-06-29 16:22, Mattias Gaertner via fpc-pascal wrote:
> On Thu, 29 Jun 2023 21:18:44 +0700
> Hairy Pixels via fpc-pascal <fpc-pascal at lists.freepascal.org> wrote:
>> What is really happening in this snippet? I think it must be
>> implicitly taking the address of the constant string but is it also
>> adding the null terminator automatically? The string prints with
>> writeln so it must be null terminated right?
>> p: Pchar;
>> p := '123';
> AFAIK the trailing #0 is already stored in the binary.
Indeed - all constant strings are already terminated with #0. Note that
this is not guaranteed for all string variables per se.
More information about the fpc-pascal