[fpc-pascal] more questions on storage
Marco van de Voort
marcov at stack.nl
Wed Sep 26 16:29:20 CEST 2007
> Am Mittwoch, den 26.09.2007, 13:24 +0200 schrieb Marco van de Voort:
> > > >
> > > > Ansistrings (and thus {$longstrings on}) work fine.
> > >
> > > Ah, okay. The Fog is lifting fastly. :)
> > >
> > > And AnsiStrings are pretty much compatible to C's char*. Very handy.
> >
> > Yes, though ansistrings may contain #0's.
>
> Interesting, how will a cast handle this case?
> Will it change the intermediate #0 to something else or will the
> resulting pchars be cut at first occurrence?
A cast is really a cast. IOW the cast pchar(ansistring) is mostly a no-op.
Traditional C code then usually treats the #0 as end of string.
It's mostly important when ansisstring is abused as general purpose buffer,
but generally it is better to use dyn arrays for that.
More information about the fpc-pascal
mailing list