[Lazarus] strcat problem

wkitty42 at windstream.net wkitty42 at windstream.net
Sat Jun 25 15:41:39 CEST 2016


On 06/23/2016 10:06 AM, Koenraad Lelong wrote:
> Hi,
>
> I used strcat to make a long PChar.
> On my OpenSuse-box this works fine. On the RaspberryPi, is gives a runtime error
> 216.
> Any suggestions what could be the problem ?

FWIW: i know you probably have your solution already as i missed this when you 
first posted it... i came up with two solutions that seem to work ok... i'm not 
sure which i prefer, though...

edit: wow... now that i've read the thread(s), it is kinda funny how that saying 
about "only so many ways to do X" comes to play... FWIW: these two below? their 
compiled sizes are only about 100 bytes different...


program pchartest1;

uses
   strings;

var
   cTekst : pchar;

begin
   cTekst := strAlloc(600);
   strCat(cTekst, #10);
   strCat(cTekst, 'Now is the winter of our discontent'#10);
   strCat(cTekst, 'Made glorious summer by this sun of York;'#10);
   strCat(cTekst, 'And all the clouds that lour''d upon our house'#10);
   strCat(cTekst, 'In the deep bosom of the ocean buried.'#10);
   strCat(cTekst, 'Now are our brows bound with victorious wreaths;'#10);
   strCat(cTekst, 'Our bruised arms hung up for monuments;'#10);
   strCat(cTekst, 'Our stern alarums changed to merry meetings,'#10);
   strCat(cTekst, 'Our dreadful marches to delightful measures.'#10);
   strCat(cTekst, 'Grim-visaged war hath smooth''d his wrinkled front;'#10);
   strCat(cTekst, 'And now, instead of mounting barded steeds'#10);
   strCat(cTekst, 'To fright the souls of fearful adversaries,'#10);
   strCat(cTekst, 'He capers nimbly in a lady''s chamber'#10);
   strCat(cTekst, 'To the lascivious pleasing of a lute.'#10);
   writeln(cTekst);
   strDispose(cTekst);
end.


program pchartest2;

const
   cTekst : ansistring =
              #10
              +'Now is the winter of our discontent'#10
              +'Made glorious summer by this sun of York;'#10
              +'And all the clouds that lour''d upon our house'#10
              +'In the deep bosom of the ocean buried.'#10
              +'Now are our brows bound with victorious wreaths;'#10
              +'Our bruised arms hung up for monuments;'#10
              +'Our stern alarums changed to merry meetings,'#10
              +'Our dreadful marches to delightful measures.'#10
              +'Grim-visaged war hath smooth''d his wrinkled front;'#10
              +'And now, instead of mounting barded steeds'#10
              +'To fright the souls of fearful adversaries,'#10
              +'He capers nimbly in a lady''s chamber'#10
              +'To the lascivious pleasing of a lute.'#10#0;

begin
   writeln(pchar(cTekst));
end.

-- 
  NOTE: No off-list assistance is given without prior approval.
        *Please keep mailing list traffic on the list* unless
        private contact is specifically requested and granted.



More information about the Lazarus mailing list