Because AFAIK, the length of a string is only 256 ... 

Strings are from 0..255 which is 256 characters.

HTH
Fred


----- Original Message ----- 
From: "Wilfried Mestdagh" <[EMAIL PROTECTED]>
To: <Delphi-Talk@elists.org>
Sent: Wednesday, October 25, 2006 1:35 PM
Subject: concatenate pchar with char and convert to string


> Hello,
> 
> Subject maybe not technically correct, but there is something where
> I have no explanation for it:
> 
> procedure Test(const S: string);
> begin
>    WriteLn(Length(S));
> end;
> 
> procedure TForm1.FormCreate(Sender: TObject);
> var
>    P: PChar;
> begin
>    AllocConsole;
>    GetMem(P, 512);
>    FillChar(P^, 511, ' ');
>    P[511] := #0;
>    Test(P + ^Z);           // displays 256
>    Test(string(P) + ^Z);   // displays 512 wich is correct
>    FreeMem(P);
> end;
> 
> Wy is the length of the first string only 256 ?
> I try this in Delphi 7.
> 
> ---
> Rgds, Wilfried
> http://www.mestdagh.biz
> 
> __________________________________________________
> Delphi-Talk mailing list -> Delphi-Talk@elists.org
> http://www.elists.org/mailman/listinfo/delphi-talk
> 
__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to