-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOOP_PBL.cpp
706 lines (674 loc) · 28.6 KB
/
OOP_PBL.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
#include <stdio.h> // has various functions for performing input and output.
#include <conio.h> //console input and output header file
#include <stdlib.h> //has various functions for performing general functions.
#include <string.h> // has various functions for manipulating arrays of characters.
#include <iostream> //provides basic input and output services
#include <time.h> // has various functions for manipulating date and time.
#include <fstream> //Input/output stream class to operate on files.
using namespace std;
void manage(); //User Management
void user(); //User menu
void database(); //admin menu
void res(); //reserve ticket
void displaypassdetail(); // display reservations
void cancell(); //cancel ticket
void enquiry(); //enquire about train information
void displaycan(); //display cancellations
char f[10] = "F"; //First class
char s[10] = "S"; //Second Class
int addr, ad, flag, f1, d, m, amt; //Pointer location, size, Not found status flag, day, month, amount
float tamt; //Total amount
class login //User Menu
{
public:
char id[100]; //UserID
char pass[100]; //User Password
void getid() //take input of user id and password
{
cout << "Enter your id:";
cin >> id;
cout << "Enter the password: ";
cin >> pass;
}
void displayid() //display id and password of all users
{
cout << id << "\t" << pass << endl;
}
};
class detail //Train Detail
{
public:
int tno; //Train Number
char tname[100]; //Train Name
char bp[100]; //Boarding Station
char dest[100]; //Destination Station
int c1, c1fare; //Seats in First class and fare
int c2, c2fare; //Seats in Second class and fare
int d, m, y; //Day Month Year
void getdetail() //Get Train Information from admin
{
cout << "Enter the details as follows\n";
cout << "Train no:";
cin >> tno;
cout << "Train name:";
cin.sync(); //as cin does not consume '\n' so we must flush the input buffer
cin.getline(tname, 100); // to get whitespaces upto '\n'
// or scanf(" %[^\n]s", tname); //to get whitespace
// cin >> tname;
cout << "Boarding point:";
cin >> bp;
cout << "Destination pt:";
cin >> dest;
cout << "No of seats in First class & Fare per ticket:";
cin >> c1 >> c1fare;
cout << "No of seats in Second class & Fare per ticket:";
cin >> c2 >> c2fare;
cout << "Date of travel:";
cin >> d >> m >> y;
}
void displaydetail() //Display Train detail
{
cout << tno << "\t\t" << tname << "\t" << bp << "\t\t\t" << dest << "\t\t\t";
cout << c1 << "\t\t\t" << c1fare << "\t\t\t" << c2 << "\t\t\t" << c2fare << "\t\t\t";
cout << d << "-" << m << "-" << y << "\t" << endl
<< endl;
}
};
class reser //Reservation Details
{
public:
int pnr; //PNR Number or Passenger Name Record
int tno; //Train Number
char tname[100]; //Train Name
char bp[10]; //Boarding Station
char dest[100]; //Destination Station
char pname[10][100]; //Passenger Name
int age[20]; //Passenger Age
char clas[10]; //Class
int nosr; //No. of Seats Reserved
int i;
int d, m, y; //Day Month Year
int con; //Concession amount
float amc;
void getresdet() //Get Reservation Details
{
cout << "\nEnter the details as follows\n";
cout << "\nTrain no: ";
cin >> tno;
// cout << "Train name: ";
// cin >> tname;
cout << "\nBoarding point: ";
cin >> bp;
cout << "\nDestination pt: ";
cin >> dest;
cout << "\nNo of seats required: ";
cin >> nosr;
cout << "\n\n";
for (i = 0; i < nosr; i++)
{
cout << "Passenger " << i + 1 << " Name: ";
cin.sync(); //as cin does not consume '\n' so we must flush the input buffer
cin.getline(pname[i], 100); // to get whitespaces upto '\n'
// or scanf(" %[^\n]s", tname); //to get whitespace
cout << "Passenger " << i + 1 << " Age: ";
cin >> age[i];
}
cout << "\n\nEnter Class\nF-first class\nS-second class\n: ";
cin >> clas;
cout << "\nDate of travel(DD MM YYYY): ";
cin >> d >> m >> y;
cout << "\n\nEnter the concession category\n";
cout << "1.Military\n2.Senior citizen\n";
cout << "3.Children below 5 yrs\n4.None\n: ";
cin >> con;
cout << "............END OF GETTING DETAILS............\n";
}
void displayresdet() //Display
{
cout << "\n...............................................\n";
cout << "...............................................\n";
cout << "PNR No: " << pnr;
cout << "\n\nTrain No: " << tno;
cout << "\n\nTrain Name: ";
cout << tname;
cout << "\n\nBoarding Point: ";
cout << bp;
cout << "\n\nDestination Point: ";
cout << dest;
cout << "\n\nNo of seats reserved: " << nosr;
for (i = 0; i < nosr; i++)
{
cout << "\n\nPassenger " << i + 1 << " Name:";
cout << pname[i];
cout << "\nPassenger " << i + 1 << " Age:" << age[i];
}
cout << "\n\nYour class: ";
cout << clas;
cout << "\n\nDate of reservation: " << d << "-" << m << "-" << y;
cout << "\n\nYour concession category: " << con;
cout << "\n\nYou must pay: " << amc << endl;
cout << "***********************************************\n";
cout << "***********************************************\n\n";
}
};
class canc //Cancel
{
public:
int pnr; //PNR Number or Passenger Name Record
int tno; //Train Number
char tname[100]; //Train Name
char bp[10]; //Boarding Station
char dest[100]; //Destination Station
char pname[10][100]; //Passenger Name
int age[20]; //Passenger Age
char clas[10]; //Class
int nosc; //No. of Cancellations
int d, m, y;
float amr;
void getcancdet() //Get cancellation details
{
cout << "Enter the details as follows\n";
cout << "PNR no: ";
cin >> pnr;
cout << "Date of cancellation(DD MM YYYY): ";
cin >> d >> m >> y;
cout << "...........END OF GETTING DETAILS...........\n";
}
void displaycancdet() //display cancelled ticket details
{
cout << "...........................................\n";
cout << "...........................................\n";
cout << "PNR No:" << pnr;
cout << "\n\nTrain No: " << tno;
cout << "\nTrain Name: ";
cout << tname;
cout << "\n\nBoarding Point: ";
cout << bp;
cout << "\n\nDestination Point: ";
puts(dest);
cout << "\n\nYour class: ";
puts(clas);
cout << "\n\nNo of seats to be cancelled: " << nosc;
for (int i = 0; i < nosc; i++)
{
cout << "\n\nPassenger " << i + 1 << " Name: ";
cout << pname[i];
cout << "\nPassenger " << i + 1 << " Age: " << age[i];
}
cout << "\n\nDate of cancellation: " << d << "-" << m << "-" << y;
cout << "\n\nYou can collect: " << amr << "rs" << endl;
cout << "*****************************************\n";
cout << ".........END OF CANCELLATION.............\n";
cout << "*****************************************\n";
}
};
int main()
{
int ch; //Choice
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout << ".......WELCOME TO RAILWAY RESERVATION SYSTEM..........\n";
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
do
{
cout << "......................MAIN MENU......................\n";
cout
<< "1.Admin mode\n2.User mode\n3.Exit\n";
cout << "Enter your choice: ";
cin >> ch;
cout << endl;
switch (ch)
{
case 1:
database(); //Admin Mode
break;
case 2:
user(); //User Mode
break;
case 3:
exit(0); //Exit
}
} while (ch < 3);
return 0;
}
void database() //Admin Menu
{
char password[15];
const char *pass = "1234"; //Default Admin Password
cout << "Enter the administrator password: ";
cin >> password;
detail a; //Train Record
fstream f; //Train Detail File
int ch; //Choice
char c; //Continuation
if (strcmp(pass, password) != 0) //Password Check
{
cout << "Enter the password correctly\n";
cout << "You are not permitted to login in this mode\n";
}
if (strcmp(pass, password) == 0) //Password Matches
{
char c;
do
{
cout << "...........ADMINISTRATOR MENU...........\n";
cout << "1.Add Train Details in Database\n";
cout << "2.Display All Trains Details\n3.User Management\n";
cout << "4.Display All Reservations\n5.Display Cancellations\n6.Return to Main Menu\n";
cout << "Enter your choice: ";
cin >> ch;
cout << endl;
switch (ch)
{
case 1:
f.open("t.txt", ios::in | ios::out | ios::binary | ios::app); //open file in read, write, binary and append mode
do
{
a.getdetail(); //Get Train Information from admin
f.write((char *)&a, sizeof(a)); //write train record to file
cout << "Do you want to add one more record?\n";
cout << "y-for Yes\nn-for No\n: ";
cin >> c;
} while (c == 'y');
f.close();
break;
case 2:
cout << "Train No.\tTrain Name\tBoarding Station\tDestination Station\tFirst Class Seats\tFirst Class Fare\tSecond Class Seats\tSecond Class Fare\tDate\n";
f.open("t.txt", ios::in | ios::out | ios::binary | ios::app); //open file in read, write, binary and append mode
f.seekg(0); //Seek read pointer to beginning of file
while (f.read((char *)&a, sizeof(a))) //reads records one by one
{
a.displaydetail(); //Display Train detail
}
f.close(); //Close file
cout << "\n\n";
break;
case 3:
manage(); //Add and See Users
break;
case 4:
displaypassdetail(); //Display All Reservations
break;
case 5:
displaycan(); //Display Cancellations
}
} while (ch < 6);
f.close(); //Close file
}
}
void displaycan() //Display Cancellations
{
fstream f3; //Cancel file
canc c; //Cancel Record
f3.open("cn.txt", ios::in | ios::out | ios::binary); //open file in read, write and binary mode
f3.seekg(0); //Seek read pointer to beginning of file
while (f3.read((char *)&c, sizeof(c))) //reads records one by one
{
c.displaycancdet(); //Displat Invidual Cancel Record
}
f3.close(); //Close File
}
void res()
{
detail a; //Train Record
reser b; //Reservation Record
fstream f1, f2; //Train and Reservation file
time_t t; //Storing Calendar time
f1.open("t.txt", ios::in | ios::out | ios::binary); //open file in read, write and binary mode
f2.open("p.txt", ios::in | ios::out | ios::binary | ios::app); //open file in read, write, binary and append mode
int ch;
cout << "\nEnter Train No.: ";
cin >> b.tno; //Choice
while (f1.read((char *)&a, sizeof(a))) //reads records one by one
{
if (a.tno == b.tno) //Train No. Check
{
cout << "\nEnter Train No. again for confirmation\n";
b.getresdet(); //Get Reservation details
if (strcmp(b.clas, f) == 0) //if First class
{
if (a.c1 >= b.nosr) //Seats check
{
strcpy(b.tname, a.tname); //Copy train name from train record to reservation record
amt = a.c1fare;
addr = f1.tellg(); //get read pointer location
ad = sizeof(a);
f1.seekp(addr - (ad)); //set write pointer one record back for updation
a.c1 = a.c1 - b.nosr;
f1.write((char *)&a, sizeof(a)); //Update Seats in Train Record
if (b.con == 1)
{
cout << "Concession category: MILITARY PERSONNEL\n";
b.amc = b.nosr * ((amt * 50) / 100); //50% concession
}
else if (b.con == 2)
{
cout << "Concession category: SENIOR CITIZEN\n";
b.amc = b.nosr * ((amt * 60) / 100); //60% concession
}
else if (b.con == 3)
{
cout << "Concession category: CHILDREN BELOW FIVE\n";
b.amc = 0.0; //Free
}
else if (b.con == 4)
{
cout << "You cannot get any concession\n";
b.amc = b.nosr * amt; //No Concession
}
srand((unsigned)time(&t)); //Initializes random number generator by seeding it. The srand() function sets the starting point for producing a series of pseudo-random integers. . time() returns a time_t value which vary everytime and hence the pseudo-random number vary for every program call.
b.pnr = rand(); //rand() function is used in C to generate random numbers.
f2.write((char *)&b, sizeof(b)); //Add Record to Reservation file
b.displayresdet(); //Display Reservation details
cout << "------------------------------------------------------\n";
cout << "--------------Your ticket is reserved-----------\n";
cout << "-----------------End of reservation menu-------\n";
}
else //Seats full
{
cout << "**********Sorry requested seats are not available********\n";
}
}
else if (strcmp(b.clas, s) == 0) //if Second class
{
if (a.c2 >= b.nosr)
{
strcpy(b.tname, a.tname); //Copy train name from train record to reservation record
amt = a.c2fare;
addr = f1.tellg(); //get read pointer location
ad = sizeof(a);
f1.seekp(addr - (ad)); //set write pointer one record back for updation
a.c2 = a.c2 - b.nosr;
f1.write((char *)&a, sizeof(a)); //Update Seats in Train Record
if (b.con == 1)
{
cout << "Concession category:MILITARY PERSONNEL\n";
b.amc = b.nosr * ((amt * 50) / 100); //50% concession
}
else if (b.con == 2)
{
cout << "Concession category:SENIOR CITIZEN\n";
b.amc = b.nosr * ((amt * 60) / 100); //60% concession
}
else if (b.con == 3)
{
cout << "Concession category:CHILDERN BELOW FIVE\n";
b.amc = 0.0; //Free
}
else if (b.con == 4)
{
cout << "You cannot get any concession\n";
b.amc = b.nosr * amt; //No Concession
}
srand((unsigned)time(&t)); //Initializes random number generator by seeding it. The srand() function sets the starting point for producing a series of pseudo-random integers. . time() returns a time_t value which vary everytime and hence the pseudo-random number vary for every program call.
b.pnr = rand(); //rand() function is used in C to generate random numbers.
f2.write((char *)&b, sizeof(b)); //Add Record to Reservation file
b.displayresdet(); //Display Reservation details
cout << "---------------------------------------\n";
cout << "--------Your ticket is reserved--------\n";
cout << "------------End of reservation---------\n";
}
else
{
cout << "********Sorry requested seats are not available*******\n";
}
}
flag = 1;
break;
}
else
{
flag = 0;
}
}
if (flag == 0)
{
cout << "............Wrong train no......................\n";
cout << "......Enter the train no from the data base.....\n";
}
f1.close();
f2.close();
}
void displaypassdetail() // display reservations
{
fstream f; //Reservation file
reser b; //Reservation Record
f.open("p.txt", ios::in | ios::out | ios::binary); //open file in read, write and binary mode
f.seekg(0); //Seek read pointer to beginning of file
while (f.read((char *)&b, sizeof(b))) //reads records one by one
{
b.displayresdet(); //Display individual record
}
f.close(); //Close fail
}
void enquiry() //enquire about train information
{
cout << "Train No.\tTrain Name\tBoarding Station\tDestination Station\tFirst Class Seats\tFirst Class Fare\tSecond Class Seats\tSecond Class Fare\tDate\n";
fstream f; //Train file
f.open("t.txt", ios::in | ios::out | ios::binary); //open file in read, write and binary mode
detail a;
while (f.read((char *)&a, sizeof(a))) //reads records one by one
{
a.displaydetail(); //dispaly individual train record
}
f.close(); //Close file
}
void cancell() //cancel ticket
{
detail a; //Train record
reser b; //Reservation record
canc c; //Cancel record
int flagc = 0; //Not found status flag
fstream f1, f2, f3, temp; //Train, Reservation, cancellation and temp file
f1.open("t.txt", ios::in | ios::out | ios::binary); //open file in read, write and binary mode
f2.open("p.txt", ios::in | ios::out | ios::binary); //open file in read, write and binary mode
f3.open("cn.txt", ios::in | ios::out | ios::binary | ios::app); //open file in read, write, binary and append mode
temp.open("temp.txt", ios::in | ios::out | ios::binary | ios::app); //open file in read, write, binary and append mode
cout << "**********CANCELLATION MENU*********\n";
c.getcancdet(); //get cancel details
while (f2.read((char *)&b, sizeof(b))) //reads records one by one
{
if (b.pnr == c.pnr) //PNR check
{
c.tno = b.tno; //Copy Train no.
strcpy(c.tname, b.tname); //Copy train name
strcpy(c.bp, b.bp); //Copy Boarding station
strcpy(c.dest, b.dest); //Copy Destination station
c.nosc = b.nosr; //Copy Seats
for (int j = 0; j < c.nosc; j++)
{
strcpy(c.pname[j], b.pname[j]); //Copy Passeger name
c.age[j] = b.age[j]; //Copy Passeger age
}
strcpy(c.clas, b.clas); //Copy class
if (strcmp(c.clas, f) == 0) //First class check
{
while (f1.read((char *)&a, sizeof(a))) //reads records one by one
{
if (a.tno == c.tno)
{
a.c1 = a.c1 + c.nosc;
d = a.d;
m = a.m;
addr = f1.tellg(); //get read pointer location
ad = sizeof(a);
f1.seekp(addr - (ad));
f1.write((char *)&a, sizeof(a)); //Update Seats in Train Record
tamt = b.amc;
//Calculate deduction amount
if ((c.d == d) && (c.m == m))
{
cout << "You are cancelling at the date of departure\n";
c.amr = tamt - ((tamt * 60) / 100);
}
else if (c.m == m)
{
cout << "You are cancelling at the month of departure\n";
c.amr = tamt - ((tamt * 50) / 100);
}
else if (m > c.m)
{
cout << "You are cancelling one atleast month before the date of departure\n";
c.amr = tamt - ((tamt * 20) / 100);
}
else
{
cout << "Cancelling after the departure\n";
cout << "Your request cannot be completed\n";
}
c.displaycancdet(); //Display cancelled Record
}
}
}
else if (strcmp(c.clas, s) == 0) //Second class check
{
while (f1.read((char *)&a, sizeof(a))) //reads records one by one
{
if (a.tno == c.tno)
{
a.c2 = a.c2 + c.nosc;
d = a.d;
m = a.m;
addr = f1.tellg(); //get read pointer location
ad = sizeof(a);
f1.seekp(addr - (ad));
f1.write((char *)&a, sizeof(a)); //Update Seats in Train Record
tamt = b.amc;
//Calculate deduction amount
if ((c.d == d) && (c.m == m))
{
cout << "You are cancelling at the date of departure\n";
c.amr = tamt - ((tamt * 60) / 100);
}
else if (c.m == m)
{
cout << "You are cancelling at the month of departure\n";
c.amr = tamt - ((tamt * 50) / 100);
}
else if (m > c.m)
{
cout << "You are cancelling one month before the date of departure\n";
c.amr = tamt - ((tamt * 20) / 100);
}
else
{
cout << "Cancelling after the departure\n";
cout << "Your request cannot be completed\n";
}
c.displaycancdet(); //Display cancelled Record
}
}
}
flagc = 1; //Found
}
else
{
if (flagc != 1)
{
flagc = 0; //Not found
}
temp.write((char *)&b, sizeof(b)); //Write every record except cancelled record
}
}
if (flagc == 0)
{
cout << "\n\nEnter the correct PNR no\n\n";
}
f3.write((char *)&c, sizeof(c)); //Add record in cancel file
f1.close(); //Close files
f2.close();
f3.close();
remove("p.txt"); //remove old Reservation File
rename("temp.txt", "p.txt"); //renames temp to new Reservation file
}
void user()
{
login a; //User Record
int flagu; //Not found status flag
int ch; //Choice
cout << "*****************************************************\n";
cout << "***********WELCOME TO THE USER MENU****************\n";
cout << "****************************************************\n";
char password[15]; //User Password
fstream f; //User file
f.open("id.txt", ios::in | ios::out | ios::binary); //open file in read, write and binary mode
char id[100]; //UserID
cout << "Enter your id: ";
cin >> id;
cout << "Enter the password: ";
cin >> password;
while (f.read((char *)&a, sizeof(a))) //reads records one by one
{
if ((strcmp(a.id, id) == 0) && (strcmp(a.pass, password) == 0)) //login check
{
do
{
cout << "1.Reserve\n2.Cancell\n3.Enquiry\n4.Return to the main menu\n";
cout << "Enter your choice:";
cin >> ch;
cout << endl;
switch (ch)
{
case 1:
res(); //reserve ticket
break;
case 2:
cancell(); //cancel ticket
break;
case 3:
enquiry(); //enquire about train information
break;
}
} while (ch <= 3);
return;
}
else
{
flagu = 1;
}
}
if (flagu == 1)
{
cout << "Enter your user id and password correctly\n";
}
}
void manage() //User Management
{
int ch; //Choice
fstream f; //User file
char c; //Continuation
login a; //User Record
cout << ".........WELCOME TO THE USER MANAGEMENT MENU........\n";
do
{
cout << "1.Add User in Database\n";
cout << "2.Display details\n3.Return to the main menu\n";
cout << "Enter your choice:";
cin >> ch;
cout << endl;
switch (ch)
{
case 1:
f.open("id.txt", ios::in | ios::out | ios::binary | ios::app); //open file in read, write, binary and append mode
do
{
a.getid(); //Store UserID and password
f.write((char *)&a, sizeof(a)); //Add to User file
cout << "Do you want to add one more record\n";
cout << "y-Yes\nn-No\n";
cin >> c;
} while (c == 'y');
f.close(); //Close file
break;
case 2:
f.open("id.txt", ios::in | ios::out | ios::binary); //open file in read, write and binary mode
f.seekg(0); //Seek read pointer to beginning of file
cout << "UserID\tPassword\n";
while (f.read((char *)&a, sizeof(a))) //reads records one by one
{
a.displayid(); //Dispaly User Record
}
f.close(); //Close file
break;
}
} while (ch < 3);
}