-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPASSENGE.CPP
89 lines (87 loc) · 1.46 KB
/
PASSENGE.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
#include<fstream.h>
#include<conio.h>
#include<stdlib.h>
#include<stdio.h>
#define o2 gotoxy(32,5); \
cout<<"I.R.C.T.C.";
class idc
{ private:
int i;
public:
idc()
{
}
idc(int a)
{ i=a;
}
int ret_id()
{ return i;
}
};
class pas
{ private:
char na[50],had[50]; //home address
int age,id;
void enter_ob()
{ ofstream f("id.dat",ios::binary|ios::app);
idc ob(id);
f.write((char *)&ob,sizeof(ob));
}
void create_id();
public:
void create_ob()
{ clrscr();
o2;
gotoxy(14,7);
cout<<"ENTER THE FOLLOWING DETAILS -";
gotoxy(13,9);
cout<<"-NAME :";
gets(na);
gotoxy(13,10);
cout<<"-HOME ADDRESS :";
gets(had);
gotoxy(13,11);
cout<<"-AGE :";
cin>>age;
create_id();
show();
enter_ob();
}
void show()
{ clrscr();
o2;
gotoxy(14,7);
cout<<"DETAILS ARE-";
gotoxy(13,9);
cout<<"-NAME :"<<na;
gotoxy(13,10);
cout<<"-HOME ADDRESS :"<<had;
gotoxy(13,11);
cout<<"-AGE :"<<age;
gotoxy(13,12);
cout<<"-ID :"<<id;
gotoxy(14,14);
cout<<"PLEASE REMEBER YOUR ID !!";
getch();
}
int ret_id()
{ return id;
}
};
void pas::create_id()
{ ifstream f("id.dat",ios::binary);
idc ob;
int flag;
do
{ flag=0;
randomize();
id=random(100);
while(f.read((char *)&ob,sizeof(ob)))
{ if(ob.ret_id()==id)
{ flag=1;
break;
}
}
}while(flag==1 || id==0);
f.close();
}