#include #include #include using namespace std; struct person { int ssnum, bdate, zip; string title, fname, lname, street, town, state; person(int ss, int bd, string t, string f, string l, string st, string tw, string sta, int z) { ssnum = ss; bdate = bd; title = t; fname = f; lname = l; street = st; town = tw; state = sta; zip = z; } void print(ostream & os) { os << title << " " << fname << " " << lname << "\n"; os << " " << street << ", " << town << ", " << state << " " << zip << "\n"; os << " born " << bdate << ", SSN " << ssnum << "\n"; } static person * read(istream & is) { int ss, bd, z; string t, f, l, st, tw, sta; is >> ss >> bd >> t >> f >> l >> st >> tw >> sta >> z; if (is.fail()) return NULL; return new person(ss, bd, t, f, l, st, tw, sta, z); } }; int main() { if (sizeof(int) < 4) { cerr << "Ints are too small on this worthless computer\n"; exit(1); } ifstream fin("/home/www/class/een318/people-1000.txt"); if (fin.fail()) { cout << "can't read file\n"; exit(1); } while (true) { person * p = person::read(fin); if (p == NULL) break; p->print(cout); delete p; } }