void person :: print() {
cout << ssn << " " << fname << " " << lname << " " << dob << "\n";
}
person ** read () {
string arrayname;
cout << "Please enter the multiple of one thousand you would like to sort" << "\n$
cin >> arrayname;
int arraysize = atoi(arrayname.c_str()) * 1000;
person * * A = new person * [arraysize + 1];
person * p = new person();
string filename = "something";
ifstream fin("something"); //tried putting filename in here but it didn't work
if (fin.fail()) {
cerr << "No file\n";
exit(1);
}
for (int i = 0; i <= arraysize; i++) {
A[i] = p;
A[i]->print();
if (i < arraysize)
fin >> A[i]->ssn >> A[i]->fname >> A[i]->lname >> A[i]->dob;
else {
A[i]->fname="Mike";
A[i]->lname="Tyson";
}
}
fin.close();
return A;
}
I'm trying to make it so that my program will take names from a text file and store them in an array until the end where it will place the name Mike Tyson. I'm doing this to make it easier to print later on and whatnot. Is there a reason that after I run this all the names become Mike Tyson?