Description
The rawwrite procedure writes up to a specified number of characters from a character buffer to a file. The actual number of characters written by this procedure may be less than the maximum number of characters specified if there is an I/O error (you can check this by disabling I/O checking and using the getlasterror function).
Parameter
The simple program below copies the contents of an input file into an output file. It is similar to the UNIX program "cat". The program uses the built-in procedures "rawread", and "rawwrite" to perform the I/O.
program cat(f, g);
const
max = 400;
var
f, g : text;
buffer : packed array[1..max] of char;
actual : integer;
begin
reset(f);
rewrite(g);
while not eof(f) do
begin
rawread(f, buffer, max, actual);
if actual <> 0 then
rawwrite(g, buffer, actual, actual);
end;
close(g);
close(f);
end.
Portability
Operating Systems: All
Standard Pascal: No