I would like to write a program that allows a user to maintain a catalog (i.e. database) of music.
The program is going to read from a data file that I will create. The data file will contain the following fields: title, artist, genre, and file name. When the program begins, it must read the entire data file into a vector containing objects of type "Song". The class "Song" must contains the fields "title", "artist", "genre" and "file name". After the catalog is read into the vector the program is not allowed to use the file until the program ends. After the program reads the catalog into a vector, it must print a menu with the following options: L (to list records), A (to add records), and D (to delete records). If the user chooses to list all records the program must iterate through the vector and print the fields of
each element in the vector using the following format:
record number (5) [tab] song (30) [tab] artist (30) [tab] genre (10) [tab] file name [newline]
1) record number indicates the position of the record in the vector
2)(#) indicates the preceding data is to be printed with width #
3) [tab] is the tab character
4) [newline] is the newline character
If the user chooses to add a record the program must prompt the user for the information necessary to
create a new Song object and add the new Song object to the vector.
If the user chooses to delete a record the program must prompt the user for a record number and then
delete from the vector the object at the position the user entered.
Before exiting the program the program must write the contents of the vector to the file mc.dat to
update the catalog.

I have the following questions and comments:
1) How do I read a data file into a vector?
2) How do I list the individual fields of the vector ("title", "artist", etc...) in the following format:
record number (5) [tab] song (30) [tab] artist (30) [tab] genre (10) [tab] file name [newline]?
3) I'd appreciate any other tips. Please Help!

1. Just read the fields one at a time into an instance of the Song class, then add the Song class to the vector

vector<Song> theList;
Song s;
infile >> s.title >> s.artist >> (etc etc for each field)

2. You can use an iterator for this

int recordno = 1;
vector<Song>::iterator it = theList.begin();
for( ; it != theList.end(); it++)
  cout << "record number: " << recordno++ << (*it).title << "\t" << (*it)artist << "\t" << (etc. etc)
This article has been dead for over six months. Start a new discussion instead.