Once info has been written into txt file, edit through command prompt

So with the help of the guys here I've managed to create a vector that stores information into a txt file.

The system function as stated below, Staff can
1) Add station (no limitation to how many can be added, station info consists of 4 strings and 1 int that have to be added)
2) View Stations (simply read the station txt file above)
3) Edit stations

The issue I'm currently facing is editing the stations. I would like to do so through the command prompt, I am not sure how exactly this will be accomplished. If the user simply drags the mouse over to the information he would like edited and starts removing/adding information that would be ideal.

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
31
32
33
34
35
36
37
38
39
void Staff::ManageSelangorRailway()
{
	int select;
	cout << "Please select one of the following options: \n\n";
	cout << "1) Add Station 2) Edit/Delete Station 3) View Station 4) Return";
	cin >> select;

	switch (select)
	{
	case 1:
	{
		vector <StationInfo> getStationInfo;
		ofstream out("SelangorStations.txt", ofstream::out | ofstream::app);
		char accept = 'y';
		char reject = 'n';
		while (tolower(accept) == 'y')
		{
			StationInfo stationInfo = GetStationInfo();
			getStationInfo.push_back(stationInfo);
			cout << endl;
			out << stationInfo;

			cout << "Would you like to add another station ? (y/n): ";
			
			if (cin >> accept)
			{
				out.close();
			}
			else if (cin >> reject)
			{
				Staff();
			}
		}
		break;
	}
	case 2:
	{
		
	}


I have searched quite a few resources and attempted to edit the code in order to make it work with mine, does not seem to be working though.

Not sure if I should fill up the question up with my failed attempts. If any of you want them I'll share.
Last edited on
For "edit", think "replace".

If the user wants to edit a station, you remove that station entirely and add a new one; whatever updated value the user entered.

The file is then rewritten, completely.
@Repeater I think I understand what your saying but no matter what I do theres always something wrong with the code, it either add on new information without removing the old or a flood of error come pouring down on me.

Been trying to solve this issue for a couple of days now.

I apologize for not replying sooner, I just didn't have anything to update you with.
At this point would anyone mind, writing out the code. I'm burnt out and would love nothing more then to understand it by actually looking at the code.
Topic archived. No new replies allowed.