Modifying specified data in a txt file

Hello everyone, my question is what should I add to the following code so that I can change the number 3 in the txt file without corrupting the data.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*******************************AddProduct()***********************************/
bool ProductClass::AddProduct(string title, float bp, float sp, int q)
{
	m_numProducts++;
	prod = new Product[m_numProducts];

	ofstream file("products.txt", ios::out | ios::app);
	if (file.fail()) return false;

	file << title << " " << bp << " " << sp << " " << q << endl;

	file.close();
}
/*****************************************************************************/

1
2
3
4
5
6
7
8
9
/***products.txt***/

numProducts: 3

bread 1 2.5 73
milk 3 2 75
water 4 3 40

/******************/
Last edited on
Did you solve it? How?
Topic archived. No new replies allowed.