In each line, There are a string and a number. I have done the search function to search for a name and it works
For example in a file with the following contents:
Batman 290
Joker 100
Spiderman 300
But the problem that I'm facing right now is how do I modify the number next to a string. For example, when I search for the name 'Batman' and I only want to change Batman's number.
Here's the code for adding:
void Teacher::addScore(string name, double score) {
    outStream.open("StudentRecord.txt", ios_base::app);
    outStream << name << " || " << score << endl;
    outStream.close();
}
For searching
string Teacher::search(string searchKeyword) {
    int count = 0;
    string name;
    readStream.open("StudentRecord.txt");
    while (readStream.is_open()) {
        getline(cin, name);
        while (readStream >> name) {
            if(name == searchKeyword) {
                count++;
                return name;
            }
        }
        if(name != searchKeyword) {
            return "That student doesnt exist";
        }
    }
    return "";
}
For modification, Im having trouble at this stage
void Teacher::modifyScore() {
    string name;
    string searchResult;
    cout << "You want to modify the a student score?" << endl;
    cout << "Which student's you want to change?" << endl;
    cin >> name;
    searchResult = search(name);
    outStream.open("StudentRecord.txt", ios::trunc);
    // What should I do here to modify a student number?  
}
 
     
     
     
     
    