ex56.pp 530 B

123456789101112131415161718192021222324252627
  1. Program Example56;
  2. { Program to demonstrate the Seek function. }
  3. Var
  4. F : File;
  5. I,j : longint;
  6. begin
  7. { Create a file and fill it with data }
  8. Assign (F,'test.dat');
  9. Rewrite(F); { Create file }
  10. Close(f);
  11. FileMode:=2;
  12. ReSet (F,Sizeof(i)); { Opened read/write }
  13. For I:=0 to 10 do
  14. BlockWrite (F,I,1);
  15. { Go Back to the begining of the file }
  16. Seek(F,0);
  17. For I:=0 to 10 do
  18. begin
  19. BlockRead (F,J,1);
  20. If J<>I then
  21. Writeln ('Error: expected ' ,i,', got ',j);
  22. end;
  23. Close (f);
  24. end.