code help pls

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
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
class employee
 {
private:
int empno,age;
char sex,name[25],desig[10],addr[30],city[15];
float msal,ysal;
public:
void indata();
void outdata();
void modify();
int retempno();
};
void employee::indata()
{
cout<<"enter employee number:";
cin>>empno;
cout<<"enter employee name:";
gets(name);
cout<<"enter age:";
cin>>age;
cout<<"enter sex:";
cin>>sex;
cout<<"enter city:";
gets(city);
cout<<"enter address:";
gets(addr);
cout<<"enter designation:";
gets(desig);
cout<<"enter monthly salary:";
cin>>msal;
}
void employee::outdata()
{
cout<<"\nemployee number:"<<empno;
cout<<"\nemployee name:"<<name;
cout<<"\neage:"<<age;
cout<<"\nsex:"<<sex;
cout<<"\ncity:"<<city;
cout<<"\naddress:"<<addr;
cout<<"\ndesignation:"<<desig;
cout<<"\nmonthly salary:"<<msal;
ysal=msal*12.0;
cout<<"\nannual income:"<<ysal;
}
int employee::retempno()
{
return empno;
}

void employee::modify()
{

cout<<"\nemployee number:"<<empno;
cout<<"\nemployee name:"<<name;
cout<<"\neage:"<<age;
cout<<"\nsex:"<<sex;
cout<<"\ncity:"<<city;
cout<<"\naddress:"<<addr;
cout<<"\ndesignation:"<<desig;
cout<<"\nmonthly salary:"<<msal;

int mempno,mage;
char msex,mname[25],mdesig[10],maddr[30],mcity[15];
float mmsal,mysal;

cout<<"enter new employee number(enter '-1' to retain old one):";
cin>>mempno;
cout<<"enter new  employee name:(enter . to retain old one):";
gets(mname);
cout<<"enter new  age(enter '-1' to retain old one):";
cin>>mage;
cout<<"enter new sex(enter '.' to retain old one):";
cin>>msex;
cout<<"enter new city(enter '.' to retain old one):";
gets(mcity);
cout<<"enter new address(enter '.' to retain old one):";
gets(maddr);
cout<<"enter new designation(enter '.' to retain old one):";
gets(mdesig);
cout<<"enter new monthly salary(enter '-1.0' to retain old one):";
cin>>mmsal;

if(strcmp(mname,".")!=0)
strcpy(name,mname);
if(strcmp(mdesig,".")!=0)
strcpy(desig,mdesig);
if(strcmp(mcity,".")!=0)
strcpy(city,mcity);
if(strcmp(maddr,".")!=0)
strcpy(addr,maddr);
if(msex!='.')
sex=msex;
if(mempno!=-1)
empno=mempno;
if(mmsal!=-1)
mmsal=msal;
ysal=(12.00*msal);
}

void search()
{
employee se; 
fstream sf;
sf.open("employee.dat",ios::in|ios::app);
int flags=0,emprno,i=0;
cout<<"enter employee number :";
cin>>emprno;
while(!sf.eof())
{
sf.read((char*)&se,sizeof(se)); i++;
if(se.retempno()==emprno)
{
cout<<"Search successfull";
se.outdata();
flags=1;
}
}
if(flags==0)
cout<<"specified data not found";
 sf.close();
}

void add()
{
fstream fa; employee ea;
fa.open("employee.dat",ios::in|ios::app);
char ch;
do{
ea.indata();
fa.write((char*)&ea,sizeof(ea));
cout<<"do you want to add more records(y/n):";
cin>>ch;
}while(ch=='y'||ch=='Y');  fa.close();
}

void delete()
{
ifstream fd;
ofstream ft;
fd.open("employee.dat");
ft.open("temp.dat");
int flagd=0;
char conf='y';
employee ed;
cout<<"enter employee number to delete:";
int enodel; cin>>enodel;
while(!fd.eof())
{
fd.read((char*)&ed,sizeof(ed));
if(ed.retempno()==enodel)
{
flagd=1;
cout<<"record preparing for delete";
ed.outdata();
cout<<"do you want do delete this record(y/n):";
cin>>conf;
if(conf=='n')
f2.write((char*)&ed,sizeof(ed));
}
f2.write((char*)&ed,sizeof(ed));
}
if(flagd==0)
cout<<"specified employee not found ";
remove("employee.dat");
rename("temp.dat","employee.dat");
cout<<"process complete";
fd.close(); ft.close();
}
void main()
{
clrscr();
employee e; int ch;flag=0;
cout<<"\n1.add a record\n2.delete a record\n3.search for a record\n4.modify a record\n5.exit\nenter choice:";
cin>>ch;
if(ch==1)
add();
else if(ch==2)
delete();
else if(ch==3)
search();
else if(ch==4)
{
cout<<"enter employee no to modify:"; 
int empnom; cin>>empnom;
ifstream f;
f.open("employee.dat";
while(!f.eof()){
f.read((char*)&e,sizeof(e));
if(e.retempno()==empnom)
{
flag==1;
cout<<"record found";
e.modify();
}
if(flag==0)
cout<<"record not found":
}
else if(ch==5)
exit(0);
else
cout<<"wrong choice";
f.close();
getch();
}


Only 1 error in this code in line 142
declaration terminated incorrectly

Please help
cheers
cyber dude
you have use the delete reserved keyword, change that function name to something else
thyanks man thank u so much

void delete()


delete is a reserved word -keyword- try to modify function's name
thanks i figured it out
Topic archived. No new replies allowed.