Name
PChar Type
Syntax
type PChar = ^Char;
Description
The PChar
type is a pointer to
Char
and with Delphi’s extended syntax, it
can also be treated as a string
or a pointer to an
array of Char
.
Tips and Tricks
PChar
is used most often as a parameter type for DLLs written in C or C++, such as the Windows API.You can treat a
PChar
pointer as a pointer to an array ofChar
. The array index is anInteger
subrange, starting from zero. Delphi does not provide any bounds checking for the array. The convention is that the end of the string is denoted by the presence of the#0
character.Perform pointer arithmetic on a
PChar
pointer by adding and subtracting integers similar to the way theInc
andDec
procedures work.Delphi’s extended syntax is enabled by default. Use the
$X
or$ExtendedSyntax
compiler directive to disable this feature and revert to behavior closer to standard Pascal.
See Also
AnsiChar Type, AnsiString Type, Array Keyword, Char Type, PAnsiChar Type, PWideChar Type, String Keyword, $ExtendedSyntax Compiler Directive, $X Compiler Directive |
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.