[Lazarus] strcat problem
David W Noon
david.w.noon at googlemail.com
Fri Jun 24 21:31:03 CEST 2016
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, 24 Jun 2016 20:37:52 +0200, Koenraad Lelong
(lazarus2 at de-brouwerij.be) wrote about "Re: [Lazarus] strcat problem"
(in <576D7E00.7010206 at de-brouwerij.be>):
[snip]
> Thanks, although I still don't grasp how PChar should be used.
The PChar type is a pointer to a NUL-terminated string. It uses C
semantics and C-like syntax.
program pchar_test;
uses strings;
var
cTekst: PChar;
begin
cTekst := StrAlloc(200); { String buffer of 200 bytes. }
{ This is how we assign and concatenate strings in C. }
StrCopy(cTekst, #13'Now is the winter of our discontent'#13);
StrCat(cTekst, 'Made glorious summer by this sun of York'#13);
StrCat(cTekst, 'And all the clouds that lour''d upon our ');
StrCat(cTekst, 'house'#13);
writeln(cTekst^); { De-reference the pointer. }
StrDispose(cTekst); { Free the string buffer. }
end.
After reading this, you should now know why C sucks as a string
processing language, and why C++ implemented the std::string class to
replace all this function call buffoonery.
- --
Regards,
Dave [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.noon at googlemail.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iEYEARECAAYFAldtincACgkQogYgcI4W/5TjPwCfQdXlunrHTf4DSCse9JcM8DyG
6VUAn1KpAtlDH2J4BR7HPxATKVsNTVHy
=+TJI
-----END PGP SIGNATURE-----
More information about the Lazarus
mailing list