-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathallorderclear.cpp
More file actions
56 lines (55 loc) · 1.38 KB
/
allorderclear.cpp
File metadata and controls
56 lines (55 loc) · 1.38 KB
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
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include "classes.h"
using namespace std;
void Courier::allorderclear(string courierfile, string orderfile){
ofstream f;
f.open(orderfile, ios::out);//делаем пустым файл с заказами
f.close();
ifstream fin;
ofstream fout;
fin.open(courierfile); //открываем
int i=0;
int k=0;
string s;
while (!fin.eof()){//считываем построчно, считаем строки
getline(fin, s);
k++;
}
k--;
int sidc;
string sname;
string sphone;
int sorderid1;
int sorderid2;
int scar;
int sdeliverytime;
Courier *a = new Courier[k+1];
fin.close();
fin.open(courierfile);
for (i=0; i<k; i++){
fin >> sidc;
fin >> sname ;
fin >> sphone;
fin >> sorderid1;
fin >> sorderid2;
fin >> scar;
fin >> sdeliverytime;
a[i].setidc(sidc);
a[i].setname(sname);
a[i].setphone(sphone);
a[i].setorderid1(sorderid1);
a[i].setorderid2(sorderid2);
a[i].setcar(scar);
a[i].setdeliverytime(sdeliverytime);
}
fin.close();
fout.open(courierfile,ios::out);
for (i=0; i<k; i++){ //перезаписываем данные курьеров обратно, но с id заказов и временем доставки =0
fout << a[i].getidc() <<" "<<a[i].getname()<<" "<<a[i].getphone()<<" "<<0<<" "<<0<<" "<<a[i].getcar()<<" "<<0<<endl;
}
fout.close();
delete[]a;
}