
May 22nd, 2003, 10:38 PM
|
|
Junior Member
|
|
Join Date: May 2003
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
heres the whole program
PHP Code:
#include <iostream.h>
#include <fstream.h>
#include "apstring.h"
#include "apvector.h"
#include <iomanip.h>
struct BookInfoType
{
apstring Title;
apstring Author;
apstring ISBN;
apstring PubName;
int PubYear;
};
struct Book
{
int number;
apvector<BookInfoType> list;
};
void getData(Book &data);
void printData(Book &data);
main()
{
Book data;
getData(data);
printData(data);
return 0;
}
void getData(Book &data)
{
ifstream infile("data.txt", ios::in);
infile >> data.number;
data.list.resize(data.number);
int i = 0;
while((!infile.eof() && i < data.number))
{
getline(infile, data.list[i].Title);
infile >> data.list[i].Title;
infile >> data.list[i].PubYear;
infile >> data.list[i].ISBN;
i++;
}
}
void printData(Book &data)
{
for(int k = 0; k < data.number; k++)
{
cout << data.list[k].Title << setw(10);
cout << data.list[k].PubYear << setw(10);
cout << data.list[k].ISBN << setw(10);
cout << endl;
}
cout << endl;
}
-------------
HELP I am screwed. I have finals and I need to know how to do this. I have searched all over the internet without finding an example of this.
Last edited by rpgwh : May 22nd, 2003 at 10:48 PM.
|