-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
107 lines (79 loc) · 2.35 KB
/
main.cpp
File metadata and controls
107 lines (79 loc) · 2.35 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
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
#include<fstream>
#include<iostream>
#include<fstream>
#include<stdio.h>
using namespace std;
class emp
{
char name[25],gender,fnam[25];
int eno;
float basic;
public:
void input()
{
cout<<"\nName:";
cin>>name;
cout<<"Gender :";
cin>>gender;
cout<<"Enter the employee number assigned :";
cin>>eno;
cout<<"Basic Pay :";
cin>>basic;
}
void output()
{
cout<<"Name :";
puts(name);
cout<<"Gender :";
cout<<gender;
cout<<"\nEmployee number :";
cout<<eno;
cout<<"\nBasic Pay :";
cout<<basic<<endl<<endl;
}
void write()
{
emp obj;
ofstream f;
f.open("emp.txt",ios::app);
cout << "\x1b[2J\x1b[1;1H" << flush;
obj.input();
f.write((char*)&obj,sizeof(obj));
f.close();
}
void read()
{ cout<<"2";
emp obj;
ifstream f;
f.open("emp.txt");
cout << "\x1b[2J\x1b[1;1H" << flush;
while(f.read((char*)&obj,sizeof(obj)));
obj.output();
f.close();
}
};
int main()
{
emp e;
int a;
cout << "\x1b[2J\x1b[1;1H" << flush;
do
{
cout << "\x1b[2J\x1b[1;1H" << flush;
cout<<"\n1.Enter biodata";
cout<<"\n2.Display biodata";
cout<<"\n3.Exit";
cout<<"\nEnter your choice"<<endl;
cin>>a;
switch(a)
{
case 1:
e.write();
break;
case 2:
e.read();
break;
}
}while(a!=3);
return 0;
}