Accessing String Characters


Strings can easily be accessed through a pointer (see Listing 9-5) because all strings (except ShortString) are null-terminated. In memory, there is always a #0 character at the end of a string.

Listing 9-5: Accessing the string through a pointer

image from book
program Project1; {$APPTYPE CONSOLE} uses   SysUtils; var   s: string;   c: PChar; begin   s := 'Borland Delphi';   c := Pointer(s);     { point to s[1] }   { display the string }   while c^ <> #0 do   begin     Write(c^);     Inc(c);   end;   Readln; end.
image from book



Inside Delphi 2006
Inside Delphi 2006 (Wordware Delphi Developers Library)
ISBN: 1598220039
EAN: 2147483647
Year: 2004
Pages: 212
Authors: Ivan Hladni

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net