-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntryInCabDatabase.cpp
More file actions
56 lines (53 loc) · 1.48 KB
/
Copy pathEntryInCabDatabase.cpp
File metadata and controls
56 lines (53 loc) · 1.48 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<bits/stdc++.h>
using namespace std;
typedef struct cab
{
int id;
char cabno[9];
int pickup;
char driver_name[6];
int drop;
char cab_name[6];
int cab_status; //Enter only 1 or 0. 1 for cab is not available, 0 for cab is available
int avg_rating,earnings;
int noofbookings;
}cab;
int main()
{
fstream fil,fil2;
int i=0;
cab ob;
fil.open("cabdatabase.txt",ios::out);
while(i<=10)
{
cout<<"Enter cab number: "<<endl;
cin>>ob.cabno;
cin.clear();
cout<<"Enter cab booking status: "<<endl;
cin>>ob.cab_status;
cin.clear();
cout<<"Enter driver_name: "<<endl;
cin>>ob.driver_name;
cin.clear();
cout<<"Enter cab's current pickup: "<<endl;
cin>>ob.pickup;
cin.clear();
cout<<"Enter cab name: "<<endl;
cin>>ob.cab_name;
cin.clear();
cout<<"Enter cab's current drop: "<<endl;
cin>>ob.drop;
cin.clear();
ob.avg_rating=5;
cout<<"Enter cab's earnings till now: "<<endl;
cin>>ob.earnings;
cin.clear();
cout<<"Enter cab's total no. of booking with us till now: "<<endl;
cin>>ob.noofbookings;
cin.clear();
ob.id=((int)(ob.cabno[5])*1000) + ((int)(ob.cabno[6])*100) + ((int)(ob.cabno[7])*10) + ((int)(ob.cabno[8]));
fil.write((char*) &ob,sizeof(ob));
i++;
}
fil.close();
}