Yurttas/PL/OOL/Cplusplus/F/06/01/io 10.cpp
Jump to navigation
Jump to search
1/*
2 Copyright(C) 1998
3 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4
5 Permission to use, copy, modify, and distribute this
6 software and its documentation for EDUCATIONAL purposes
7 and without fee is hereby granted provided that this
8 copyright notice appears in all copies.
9
10 date : January 1, 1998.
11 author : Salih Yurttas.
12
13 io_10.cpp
14*/
15
16
17#include <iostream>
18
19#include <fstream>
20
21using namespace std;
22
23void double_space(ifstream& i_f,
24 ofstream& o_f) {
25 char c;
26
27 while(i_f.get(c)) {
28 o_f.put(c);
29 if(c=='\n')
30 o_f.put(c);
31 }
32}
33
34
35int main(int argc, char* argv[]) {
36
37 if(argc != 3 ) {
38 cout << "\nUsage: " << argv[0]
39 << " infile outfile\n";
40 exit(1);
41 }
42
43 ifstream f_in(argv[1]);
44 ofstream f_out(argv[2]);
45
46 if(!f_in) {
47 cerr << "cannot open " << argv[1];
48 exit(1);
49 }
50
51 if(!f_out) {
52 cerr << "cannot open " << argv[2];
53 exit(1);
54 }
55
56 double_space(f_in,
57 f_out);
58
59}