-
Notifications
You must be signed in to change notification settings - Fork 0
/
EX06d-io-converter.cpp
37 lines (34 loc) · 1.26 KB
/
EX06d-io-converter.cpp
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
#include <iostream> // for using cout
#include <fstream> // for using ifstream / ofstream
#include <string> // for using string
using namespace std; // for std functions
#define MAX_ZEILE 100
int main(int argc , char *argv [])
//int main()
{
//----------------------------------------------------------------
cout << "EX06d-io-converter: A simple converter" << endl;
//----------------------------------------------------------------
ifstream input_file; // Instance of class ifstream
//input_file.open("coordinates.txt"); // Open file "text_file.txt"
input_file.open(argv [1]);
ofstream output_file; // Instance of class ifstream
//output_file.open("output_file.txt"); // Open file "text_file.txt"
output_file.open(argv [2]);
//----------------------------------------------------------------
char line[MAX_ZEILE];
int i=1;
int summe=0;
while(input_file.getline(line,MAX_ZEILE))
{
if (i<0)
continue;
output_file << i << "," << line << endl;
summe += i;
i++;
}
output_file << "Summe der Zeilen ist: " << i-1 << endl;
cout << "Summe der Zeilen ist: " << i-1 << endl;
//----------------------------------------------------------------
return 0;
}