1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
/* mycopy4.cc */
#include <cstdlib>
#include <iostream>
#include <fstream>
#include "mycopy4_clp.h"
using namespace std;
#define VERSION "3.0"
int main (int argc, char *argv[])
{
int i;
char c;
ifstream input_file;
ofstream output_file;
bool ofile = false, ifile = false;
Cmdline cl (argc, argv);
if (cl.v ())
{
cout << argv[0] << " version " << VERSION << endl;
exit (0);
}
if (!cl.o ().empty ())
{
output_file.open (cl.o ().c_str ());
ofile = true;
}
if (cl.next_param ())
{
input_file.open (argv[cl.next_param ()]);
ifile = true;
}
for (i = 0; i < cl.i (); i++)
{
if (ifile) c = input_file.get ();
else cin >> c;
while (c != EOF)
{
if (ofile) output_file.put (c);
else cout << c;
if (ifile) c = input_file.get ();
else cin >> c;
}
if (ifile)
{
input_file.clear ();
input_file.seekg (0);
}
}
input_file.close ();
output_file.close ();
return 0;
}
|