TStream.StrRead
Read a null-terminated string from the stream.
Declaration
Source position: objects.pp line 314
default
function 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
Name | Description |
---|---|
TStream.ReadStr | Read a shortstring from the stream. |
TStream.StrWrite | Write a null-terminated string to 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.