Dsa 11
Dsa 11
#include <fstream>
#include <cstring>
class tel
public:
char name[10];
char div;
char address[20];
void accept()
void accept2()
void accept3()
int getRollNo()
return rollNo;
void show()
cout << "\n\t" << rollNo << "\t\t" << name << "\t\t" << div << "\t\t" << address;
};
int main()
int i, n, ch, ch1, rec, start, count, add, n1, add2, start2, n2, y, a, b, on, oname, add3, start3, n3, y1,
add4, start4, n4;
tel t1;
count = 0;
fstream g, f;
do
switch (ch)
case 1:
f.open("StuRecord.txt", ios::out);
x:
t1.accept();
if (ch1 == 1)
goto x;
else
f.close();
break;
case 2:
f.open("StuRecord.txt", ios::in);
while (f)
t1.show();
f.close();
break;
case 3:
while (f)
if (rec == t1.rollNo)
{
add = f.tellg();
f.seekg(0, ios::beg);
start = f.tellg();
t1.accept();
f.close();
count++;
break;
if (count == 0)
f.close();
break;
case 4:
cout << "\nEnter the name you want to find and edit";
while (f)
y = (strcmp(name, t1.name));
if (y == 0)
f.seekg(0, ios::beg);
start2 = f.tellg();
t1.accept();
f.close();
break;
break;
case 5:
while (f)
if (on == t1.rollNo)
add3 = f.tellg();
f.seekg(0, ios::beg);
start3 = f.tellg();
t1.accept2();
f.close();
break;
break;
case 6:
cout << "\nEnter the name you want to find and edit";
while (f)
y1 = (strcmp(name2, t1.name));
if (y1 == 0)
add4 = f.tellg();
f.seekg(0, ios::beg);
start4 = f.tellg();
t1.accept3();
f.close();
break;
break;
case 7:
int roll;
cout << "Please Enter the Roll No. of Student Whose Info You Want to Delete: ";
f.open("StuRecord.txt", ios::in);
g.open("temp.txt", ios::out);
while (!f.eof())
if (t1.getRollNo() != roll)
cout << "The record with the roll no. " << roll << " has been deleted " << endl;
f.close();
g.close();
remove("StuRecord.txt");
rename("temp.txt", "StuRecord.txt");
break;
case 8:
break;