home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_04
/
1104106a
< prev
next >
Wrap
Text File
|
1993-01-30
|
1KB
|
52 lines
#include <iostream.h>
#include "int_file.hpp"
#include "boolean.hpp"
#include "program.hpp"
main()
{
Internal_File old_file;
Internal_File new_file;
Internal_ByteArray buffer(100);
Internal_ByteSize bytes;
Boolean done;
old_file.open(FileName("abc.dat"));
if (old_file.error() == Internal_File::No_error)
{
cout << "Unable to open file abc.dat";
program_exit(Failure);
}
new_file.create(FileName("def.dat"));
if (new_file.error() == Internal_File::No_error)
{
cout << "Unable to open for writing def.dat";
program_exit(Failure);
}
// Copy the files
do
{
old_file.read(buffer);
switch(old_file.error())
{
case Internal_File::No_error:
done = False;
break;
case Internal_File::End_of_file:
done = True;
break;
default:
cout << "Error in reading";
done = True;
break;
}
new_file.write(buffer);
if (new_file.error() != Internal_File::No_error)
{
cout << "Error in writing";
done = True;
break;
}
} while (!done);
old_file.close();
new_file.close();
}