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
|
int main(int argc, char *argv[])
{
if(argc != 3)
{
cerr << "Incorrect command-line args"
<< " Need 3 now " << argc << endl;
return -1;
}
ifstream input(argv[argc - 2]);
ofstream output(argv[argc - 1], ofstream::app);
Sales_data total;
if(read(input, total))
{
Sales_data trans;
while(read(input, trans))
{
if(total.isbn() == trans.isbn())
total.combine(trans);
else
{
print(output, total) << endl;
total = trans;
}
}
print(output, total) << endl;
}
else
cerr << "No data?" << endl;
}
|