I need help with my eiditing a record function, I'm struggling to get it to work. Thank you

int Search(Student List[], int Size, string Target)
{
    for(int i = 0 ; i < Size ; i++)
        if (Target == List[i].LastName)
            return i;
    return -1;
}


void Edit_Record(Student List[], Student & Temp)
{
    int Size = 0;
    string Target;
    int Index;
    cout << "\nEnter a name to search for (Last Name e.g. Smith): ";
    getline(cin,Target);
    Index = Search(List,Size,Target);
    if (Index!=-1){
        cout<<"Procede to change the student's information"<<endl;

        cout << "Enter Student" << List[Index].LastName + ", " + List[Index].FirstName << "'s new information" << endl;
        cout << "Enter the new First Name: ";
        cin >> List[Index].FirstName;
        cout << "Enter the new Last Name: ";
        cin >> List[Index].LastName;
        cout << "Enter the new Quiz Score: ";
        cin >> List[Index].Quiz;
            cout << setw(20) <<"Scores for Six Tests:" << endl ;
            for (int j = 0 ; j < 6 ; j++)
            {
                cout <<setw(7)<< " Test # " << j+1 << ": " ;
                cin >> List[Index].Test[j];

            }
    }
    else
        cout << "\nThis student information does not exist on the list. Try again.\n";

}

Here should to write

int Search(Student List[], int Size, string Target)
{
    for(int i = 0 ; i < Size ; i++)
        if (Target == List[i].LastName)
            return i;
            // You sould to write else of not you can not return tow int 
            // in the same time 
        else 
        // try this code 
    return -1;
}

And if you have tow students with the same last name .

Edited 2 Years Ago by zouhair.kasmi

This article has been dead for over six months. Start a new discussion instead.