home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_07
/
1107110a
< prev
next >
Wrap
Text File
|
1993-04-29
|
658b
|
37 lines
// copy5.cpp: Copy one file to another
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <stdlib.h>
main(int argc, char *argv[])
{
ifstream inf;
ofstream outf;
// Open optional input file
if (argc > 1)
inf.open(argv[1]);
else
inf.attach(fileno(stdin));
// Open optional output file
if (argc > 2)
outf.open(argv[2]);
else
outf.attach(fileno(stdout));
if (inf && outf)
{
char c;
while (inf.get(c))
outf.put(c);
return EXIT_SUCCESS;
}
else
return EXIT_FAILURE;
}