//File: records.cpp #include #include using namespace std; int main() { struct student_record //defines a new type { string name; //three data fields int age; double gpa; }; //NOTE: You need the semicolon here! student_record student; //defines a variable of student_record type ifstream fin ("students_in.txt"); ofstream fout ("students_out.txt"); while (!fin.eof()) { fin >> student.name >> student.age >> student.gpa; fout << student.name << "\t" << student.age << "\t" << student.gpa << endl; } return 0; // NOTE: Output of results reflects the dot notation used above. // You can't input or output records or struct's in the aggregate. // That is, the following are illegal: // cin >> student; or cout << student; // However, you can make aggregate assignments; i.e., the following is OK: // student1 = student2; // In this case, each field of student2 is copied to the corresponding // field of student1. }