I've been learning C/C++ and I'm currently doing an ATM project. It all works fine but I would like to improve it so when i quit the program and it will load the data used previously.
currently I use a struct like this
struct database {
int pin, sort, account, trans; // pin, sortcode, account number and what transaction number their on
float balance; // balance
string history[20]; // last 20 transactions
string name; // name
} data [PEOPLE]; // name is data and their are "PEOPLE" amount of records
and I currently load my data at the start like this and imports the data into the variables
void populate()
{
int i;
data[0].pin=1234;
data[0].sort=123456;
data[0].account=12341234;
data[0].balance=456.43;
data[0].name = "Mr. Sam Berwick";
data[0].trans= 0;
for(i=0;i!=19;i++)
{
data[0].history[i] = " ";
}
data[1].pin=2341;
data[1].sort=234561;
data[1].account=23412341;
data[1].balance=4532.78;
data[1].name = "Mr. David Reynolds";
data[1].trans= 0;
for(i=0;i!=19;i++)
{
data[1].history[i] = " ";
}
}
How would I set it up so It imports a text file like this
1234
123456
12341234
456.43
Mr. Sam Berwick
0
2341
234561
23412341
etc