Substring.ToPChar Method

function ToPChar: PChar;

A pointer to the text, terminated by #0, valid until the string next changes.

Returns: PChar

Remarks:

A #0 already after the text is used as it is. Otherwise no character is overwritten and no memory taken: where the #0 cannot be placed after the text without either, ESubstringInPlaceError is raised, and MakeUnique first makes the call work.

Examples

A C string from a Substring.

uses Substr;

procedure Example;
var s: Substring;
    P: PChar;
begin
    s := Substring('abc');
    P := s.ToPChar;
    Assert((P[0] = 'a') and (P[3] = #0));
end;
See Also: Substring.op_Explicit, Substring.op_Explicit, Substring.op_Explicit, Substring.op_Explicit