delete data from a file c++

i want to delete some data from a file that has been already containing some data. Actually i want to delete a record. for example. i have a record of many students in a file. and i want to delete 1 student record from file. anyone help me?
this program is using linked list.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
string del()
	{
		ofstream studentFile;
		studentFile.open("Student.txt",ios::in | ios::out | ios::app);
		student *temp=last->previous;
		student *p;
		p=new student();

		p=last->previous;

		last->previous=temp->previous;

		delete(temp);

		studentFile<<p->Name<<endl;
		studentFile<<p->reg_no<<endl;

		studentFile.close();

		return (0);
	}

Topic archived. No new replies allowed.