[Lazarus] strcat problem
maaartinus at gmail.com
Thu Jun 23 21:38:49 CEST 2016
Have you checked if there's any room behind #13'Now is the winter of our
discontent'#13, so that someone else's memory won't get overwritten? I'd
bet, there's none.
*Appends a copy of the source string to the destination string. The
terminating null character in destination is overwritten by the first
character of source, and a null-character is included at the end of the new
string formed by the concatenation of both in destination.*
You'd need something like
and maybe also
cTekst[oldLength] := #0;
before the very first strcat.
On Thu, Jun 23, 2016 at 9:27 PM, Koenraad Lelong <lazarus2 at de-brouwerij.be>
> Op 23-06-16 om 21:08 schreef Koenraad Lelong:
>> Op 23-06-16 om 16:58 schreef David W Noon:
>>>> cTekst:=#13'Now is the winter of our discontent'#13;
>>> You need a trailing #0 byte on the end.
>> The definition of cTekst :
>> cTekst : PChar;
>> So the compiler knows cTekst is a 0-terminated string doesn't, it ?
>> And StrCat needs two parameters : PChar and PChar. So I think the
>> compiler knows the strings are zero-terminated.
>> Besides, on my OpenSuse-box it works, or is that by chance ?
>> Extra info :
> I checked with a hex-dumper (executables for opensuse & pi). All strings
> end with a #0. No byte-count in front of them. All start at a
> Lazarus mailing list
> Lazarus at lists.lazarus-ide.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Lazarus