Outputting a list of customers to a text file

Hey guys, I'm really struggling with this program.

I am to make a video store operational by holding customerType objects in a linked list. Each customerType object holds a vector of videos that they have rented.

I'm wondering if there is any simple way to output this information to a file, then read it into the program and store the data correctly. Ideally, I should be able to add and delete items from this list with precision.

For instance, if one customer has rented three movies, but another has 2 movies, how do I stop it from reading a customer's name as if it were a movie title.

Here is just one example of the things I've tried:

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
40
41
42
43
44
45
46
47
void createCustList(fstream& iofile, customerListType& cList, videoListType & videoList)
{
string lname, fname;
string title = " ";
int account;
vector<string> rentedList;
char ch;



iofile >> account;

while(iofile)
{
customerType newCust;
iofile >> lname;
iofile >> fname;
iofile.get(ch);

newCust.setInfo(fname, lname, account);
cList.insert(newCust);

iofile.get(ch);
cout << ch;
while (!(ch >= '0') && !(ch <= '9'))
{
cout << "inside while loop" << endl;
iofile.putback(ch);
getline(iofile, title);
cout << title << endl;
while(videoList.videoSearch(title))
{
cList.addtoList(account, title); // calls the addtoList function of customerType and adds the movie title to the vector
// in the customer specified by the account number
}

iofile.get(ch);
cout << ch << endl;
}

if(ch >= '0' && ch <= '9')
{
iofile >> account;
cout << account;
}
}
}
Last edited on
Use the code tags, please.


Ideally, you would have a relational database with three tables: 1. the customers, 2. the tapes, and 3. the loans. One record in loans refers to one customer and one tape. Libraries implement database code already, say the sqlite. That would handle most of the file formatting issues too.
Topic archived. No new replies allowed.