Program deletes a different record than what it is suppose to delete

I have two default records in my program (P1001 and P1002). When I try to delete P1001 in my program, it deletes P1002 instead. I know this because when I go to 'Display record' in my function and type in 'P1001', it still shows the record for it. However, when I enter 'P1002' it says "record does not exist".

Here is my coding:
Declarations outside main()
1
2
3
4
5
6
7
8
const int SIZE=30;
struct StudentRecord
     {
       string studentID;
       float studentMark;
     };

int linearSearch (StudentRecord*student,const string id,int totalStudents);


Declarations inside main()
1
2
3
4
5
6
7
8
9
    StudentRecord student[SIZE] = 
                  {
                  {"P1001",78.50},
                  {"P1002",66}
                  };
    StudentRecord *recPoint;
    int totalStudents=2;
    string id;
    int found;


Function for 'Delete record'
1
2
3
4
5
6
7
8
9
10
11
12
13
                cout << "Enter a Student Record:" << endl;
                cout << "Student ID -> ";
                cin >> id;
                found = linearSearch(student,id,totalStudents);
                if (found!=-1)
                  {
                     recPoint = new StudentRecord;
                     delete recPoint;
                     totalStudents--;
                     cout << endl << "Student Record has been deleted." << endl << endl;
                  }
                else
                  cout << "Record does not exist." << endl << endl;



Could somebody please fix the error. I have pretty much completed my program and this is the only thing left that I have to do.
closed account (S6k9GNh0)
We've answered this before for you. Do not repost the exact same thing and expect a different answer.
Topic archived. No new replies allowed.