How To Find Specific Data From A Text File and Change It?

  c++, fstream

I’m new to programming and I’m trying to change this code to write it to a text file.

Basically I have to find the price of an item that was stored in the array ‘List’, each pointer contains an item code, description, price and discount.

I’m having two problems though, finding the item’s price in the text file and than changing it by the user’s input.

void DoSetItemPrice(void)

     int `searchCode` = 0;

    double changePrice = 0.00;

    cout << "Enter Code For Search: ";

    cin >> searchCode;
        cout << endl;
        cout << "Enter Price Change: $";
        cin >> changePrice;
        cout << endl;
    for (int i = 0; i < numItems; i++)
              if (List[i].HasCode(searchCode) == true)
             cout << "New Price: $" << List[i].GetDiscount();
         } else
            cout << "The Code You Entered Could Not Be Found";

Source: Windows Questions C++