ex32.pp 484 B

12345678910111213141516171819202122
  1. program Example31;
  2. { Program to demonstrate the Dup function. }
  3. uses linux;
  4. var f : text;
  5. i : longint;
  6. begin
  7. Assign (f,'text.txt');
  8. Rewrite (F);
  9. For i:=1 to 10 do writeln (F,'Line : ',i);
  10. if not dup2 (output,f) then
  11. Writeln ('Dup2 Failed !');
  12. writeln ('This is written to stdout.');
  13. writeln (f,'This is written to the dup file, and flushed');
  14. flush(f);
  15. writeln;
  16. { Remove file. Comment this if you want to check flushing.}
  17. Unlink ('text.txt');
  18. end.