Yurttas/PL/OOL/Cplusplus/F/06/02/00/01/io gs 00.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_gs_00.cpp
14*/
15
16
17#include <iostream>
18#include <fstream>
19
20#include <vector>
21#include <string>
22
23using namespace std;
24
25void double_space(ifstream& in_file,
26 ofstream& out_file) {
27 vector<string> s;
28 string t;
29
30 while(getline(in_file,t,'\n')) {
31 s.push_back(t);
32 out_file << t << endl;
33 }
34 out_file << endl << endl;
35
36 int n = s.size();
37 for(int i=0; i<n; ++i)
38 out_file << s.at(i) << endl << endl;
39}
40
41
42int main(int argc, char* argv[]) {
43
44 if(argc != 3 ) {
45 cout << "\nUsage: " << argv[0]
46 << " infile outfile\n";
47 exit(1);
48 }
49
50 ifstream f_in(argv[1]);
51 ofstream f_out(argv[2]);
52
53 if(!f_in) {
54 cerr << "cannot open " << argv[1];
55 exit(1);
56 }
57
58 if(!f_out) {
59 cerr << "cannot open " << argv[2];
60 exit(1);
61 }
62
63 double_space(f_in,
64 f_out);
65
66}