//File: arrayAlt.cpp #include #include using namespace std; struct student_record { string name; int age; double gpa; }; int main() { //Using array of pointers to records could be more space efficient student_record * student[30]; ifstream fin("students_in.txt"); ofstream fout("students_out.txt"); int k; for (k=0; !fin.eof(); k++) { student[k] = new student_record; //dynamic memory allocation fin >> student[k]->name >> student[k]->age >> student[k]->gpa; } for(int j=0; j fout << (*student[j]).name << '\t' << (*student[j]).age << '\t' << (*student[j]).gpa << endl; delete student[j]; //releases memory back to heap } return 0; }