[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Objects' (#rtl)

TStream.StrRead

Read a null-terminated string from the stream.

Declaration

Source position: objects.pp line 283

function TStream.StrRead: PChar;

Description

StrRead reads a string from the stream, allocates memory for it, and returns a pointer to a null-terminated copy of the string on the heap.

Errors

On error, Nil is returned.

See also

TStream.StrWrite

  

Write a null-terminated string to the stream.

TStream.ReadStr

  

Read a shortstring from the stream.

Example

Program ex10;

{
Program to demonstrate the TStream.StrRead TStream.StrWrite functions
}

Uses objects;

Var P : PChar;
    S : PStream;

begin
  P:='Constant Pchar string';
  Writeln ('Writing to stream : "',P,'"');
  S:=New(PMemoryStream,Init(100,10));
  S^.StrWrite(P);
  S^.Seek(0);
  P:=Nil;
  P:=S^.StrRead;
  DisPose (S,Done);
  Writeln ('Read from stream : "',P,'"');
  Freemem(P,Strlen(P)+1);
end.

Documentation generated on: Mar 17 2017