combine strings and numbers from different files into a table

Hi,
I have three files and want to combine pieces of them into a table in a new file.
1st file: names of wifes, some random information, their birthdays
2nd file: names of husbands, some random information, their birthdays
3rd file: wife, husband, random information, wedding day
my table should look like this:
-wife- -bday- -husband- -bday- -wedding day-

my questions:
what is the best way to create the table? currently I'm trying it with a list of structures. the struct contains the 5 parameters.
If this is the way to go, how do I combine the data to one struct?
I want my program to just go through the files, read in the names and dates and store it in the right place.
I already have 2 vectors containing the wifes and husbands names in the right order.
how can I get the dates? (they're always in lines starting with "birthday" or "wedding day" respectively)
any suggestions welcome!

[edit: I moved this here from the Beginners Forum]
Last edited on
Separate parsing from combining if you're having a hard time, even though it could be done at the same time.

For parsing, it's hard to say anything without knowing the exact structure of the file, but you can pretty much either read a line into a string (getline), then search the string for the word you need (.find) and cut out the characters you need immediately after (.substr).

For combining, it doesn't matter whether you use a list or a vector. Are the files ordered the same way? If not, you may want to read the 1st and 2nd files into maps instead of vectors.
as your needs are very likely to change over time, I recommend you store data like this in a RDBMS (eg Mysql, MS Access) - the data will be easier to browse and you can write ad-hoc queries (directly to the database or through a C API) to generate reports
Topic archived. No new replies allowed.