-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSMS.cpp
210 lines (202 loc) · 3.54 KB
/
SMS.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
#include<bits/stdc++.h>
using namespace std;
class crim_rec
{
char name[20], standard[5], fathr_name[20], addrs[25], course[20], section[5], dob[9];
int admin;
void disp();
public:
void get();
void wtf();
void rff();
void search();
void del();
void mod();
}c;
void crim_rec::get()
{
puts("\nEnter name of student");
cin>>name;
puts("\nEnter class:");
cin>>standard;
puts("\nEnter section:");
cin>>section;
puts("\nEnter admission number of student:");
cin>>admin;
puts("\nEnter date of birth:");
cin>>dob;
puts("\nEnter father's name:");
cin>>fathr_name;
puts("\nEnter address:");
cin>>addrs;
puts("\nEnter the course:");
cin>>course;
}
void crim_rec::disp()
{
cout<<"The record of student:\n";
cout<<"\nName of student: "<<name;
cout<<"\nClass: "<<standard;
cout<<"\nSection: "<<section;
cout<<"\nAdmission number: "<<admin;
cout<<"\nDOB: "<<dob;
cout<<"\nFather's name: "<<fathr_name;
cout<<"\nAddress: "<<addrs;
cout<<"\nCourse: "<<course;
}
void crim_rec::wtf()
{
ofstream ofile;
ofile.open("CBI", ios::app);
get();
ofile.write((char*)&c, sizeof(c));
ofile.close();
}
void crim_rec::rff()
{
ifstream ifile;
ifile.open("CBI");
ifile.seekg(0, ios::beg);
ifile.read((char*)&c, sizeof(c));
while(ifile)
{
disp();
ifile.read ((char*)&c, sizeof(c));
}
ifile.close();
}
void crim_rec::search()
{
char m[20];
ifstream ifile("CBI");
puts("Enter name of student which has to be searched");
gets(m);
ifile.seekg (0, ios::beg);
ifile.read((char*)&c, sizeof(c));
while(ifile)
{
if (strcmpi(m, name)==0)
disp();
ifile.read((char*)&c, sizeof(c));
}
ifile.close();
}
void crim_rec::del()
{
char b[20];
ifstream ifile;
ifile.open("CBI", ios::app);
ofstream ofile;
ofile.open("new", ios::app);
puts("Enter the name of the student whose records you want to delete");
gets(b);
ifile.seekg (0, ios::beg);
ifile.read((char*)&c, sizeof(c));
while(ifile)
{
if (strcmpi(b, name))
ofile.write((char*)&c, sizeof(c));
ifile.read((char*)&c, sizeof(c));
}
ifile.close();
ofile.close();
remove ("CBI");
rename("new", "CBI");
}
void crim_rec::mod()
{
char d[20];
int p;
puts("\nEnter name of student whose record you want to modify\n");
gets(d);
fstream f;
f.open("CBI", ios::in|ios::out);
f.seekg(0, ios::beg);
f.read((char*)&c, sizeof(c));
int a=f.tellg();
while(! f.eof())
{
if (!strcmpi(d, name))
{
puts("\nPress 1 to change name\nPress 2 to change class\nPress 3 to change section\nPress 4 to change admission numbern\n Press 5 to change DOB\nPress 6 to change father's name\nPress 7 to change address\nPress 8 to change course\n");
cin>>p;
switch(p)
{
case 1:
gets(name);
break;
case 2:
cin>>standard;
break;
case 3:
gets(section);
break;
case 4:
cin>>admin;
break;
case 5:
gets(dob);
break;
case 6:
gets(fathr_name);
break;
case 7:
gets(addrs);
break;
case 8:
cin>>course;
break;
}
f.seekg(a-sizeof(c), ios::beg);
f.write((char*)&c, sizeof(c));
}
f.read((char*)&c, sizeof(c));
a=f.tellg();
}
f.close();
}
int main ()
{
int ch;
char choice;
do
{
cout<<"\tVBPS STUDENT INFORMATION SYSTEM";
cout<<"\n ********************************************";
cout<<"\n\n * 1. View student details";
cout<<"\n\n * 2. Add new student details";
cout<<"\n\n * 3. Search a student record";
cout<<"\n\n * 4. Delete a student record";
cout<<"\n\n * 5. Modify a student record";
cout<<"\n ********************************************";
cout<<"\n\n Enter your choice:";
cin>>ch;
switch(ch)
{
case 1:
c.rff();
break;
case 2:
c.wtf();
break;
case 3:
c.search();
break;
case 4:
c.del();
break;
case 5:
c.mod();
break;
default:
{
cout<<"\nerror!";
}
break;
}
cout<<"\ncontinue? (y/n)\n";
cin>>choice;
}while(choice=='y');
cout<<"\nGood bye";
return 0;
}