void Table::removestudent() {
string line;
fstream stdfile("Student.txt", ios::binary | ios::in | ios::out);
int removing;
cout << "Student Number of the student you are removing: " << endl;
cin >> removing;
Student *student = new Student;
while (stdfile.read((char *) student, sizeof(student))) {
if (removing == student->stdnum) {
//REMOVE CODE HERE
break;
}
}
if (removing != student->stdnum) {
cout << "Student not in the database" << endl;
}
stdfile.close();
}
You should open the file in read mode, read all students in an array, except the one you want to delete, close the file and open it in write mode, write the array to the file, then close the file. Done