ex18.pp 511 B

12345678910111213141516171819202122232425
  1. program ex18;
  2. { Program to demonstrate the TStream.Read method }
  3. Uses Objects;
  4. Var Buf1,Buf2 : Array[1..1000] of Byte;
  5. I : longint;
  6. S : PMemorySTream;
  7. begin
  8. For I:=1 to 1000 do
  9. Buf1[I]:=Random(1000);
  10. Buf2:=Buf1;
  11. S:=New(PMemoryStream,Init(100,10));
  12. S^.Write(Buf1,SizeOf(Buf1));
  13. S^.Seek(0);
  14. For I:=1 to 1000 do
  15. Buf1[I]:=0;
  16. S^.Read(Buf1,SizeOf(Buf1));
  17. For I:=1 to 1000 do
  18. If Buf1[I]<>buf2[i] then
  19. Writeln ('Buffer differs at position ',I);
  20. Dispose(S,Done);
  21. end.