Domanda

I'm reading in a tab delmited file into c++ and I want to manipulate the data. I was wondering what is a good data structure to store it in.

Here is my tab delmited file:

Account No.  Name  Address      Available Balance
15           Ted   20 John St.  100
30           John  30 Ted St.   200
50           Roy   55 Roy St.   520

I want to modify the fields in the text file, based on what commands I do. Say I want to withdraw 50 from Ted, I would need to find Ted's account, look at the available balance and subtract 50 from it, then save it back into the text file.

Is there an efficient way to do this? All I can think of is a long and convoluted way.

È stato utile?

Soluzione

Rather store your data in-memory as a vector of Account struct instances. Then modifications take place on this container. Read and write to tab-delimited file only when needed, e.g. on starting and ending the program.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top