Replacing a structure in a binary file

Hello guys, i'm having a problem with a function in my program. The function is supposed to open a file, ask the user which part of the file they would like to edit, and then replace that part of the file with the users input. My function for doing this works, but the problem it has is it always replaces the first record in the file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 void change_info()
{
	
	long num_change;
	fstream change("people.dat", ios::in | ios::out | ios::binary);
	if (!change)
	{
		cout << "Error opening file. Program aborting.\n";
	}

	cout << "which file would you like to edit\n";
	cin >> num_change;

	change.seekg(num_change* sizeof(person), ios::beg);
	change.read(reinterpret_cast<char *>(&person), sizeof (person));
	
	cout << "Enter the following information about a person:\n";
	cout << "Name: ";
	cin.ignore();
	cin.getline(person.name, NAME_SIZE);
	cout << "Phone: ";
	cin.getline(person.phone, PHONE_SIZE);

	//  I BELEIVE THE ERROR IS HERE, SINCE THIS WHAT ACTUALLY WRITES BACK INTO THE FILE
	change.seekp((num_change*sizeof(person), ios::beg));
	change.write(reinterpret_cast<char *>(&person), sizeof (person));

	change.close();

}

If anyone could give me any pointers I sure would appreciate it :)
Topic archived. No new replies allowed.