1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include "StudentRecordDataNode.h"
#include "Course.h"
#include "StudentSingleListedLink.h"
#define SIZE_BUF 15
using namespace std;
void main()
{
double marks[18];
unsigned int Age;
unsigned int ID;
unsigned int CourseCount;
char FirstName[10];
char LastName[10];
Course Courses[18];
StudentRecordDataNode *node = 0;
StudentSingleListedLink iList;
StudentRecordDataNode *nd = 0;
ifstream is;
is.open ("OOP344_Assignment_3_2011_01.dat", ios::binary );
do {
//beginning of saving records from the file
for(int i=0; i<18; i++)
marks[i] = 0;
is.read(reinterpret_cast<char *>(&marks), sizeof(double)*18);
is.read(reinterpret_cast<char *>(&Age), sizeof(Age));
is.read(reinterpret_cast<char *>(&ID), sizeof(ID));
is.read(reinterpret_cast<char *>(&CourseCount), sizeof(CourseCount));
is.read(reinterpret_cast<char *>(&FirstName), sizeof(FirstName));
is.read(reinterpret_cast<char *>(&LastName), sizeof(LastName));
for (int i=0; i < 18; i++)
{
is.read(reinterpret_cast<char *>(&Courses[i].Semester), sizeof(Courses[i].Semester));
is.read(reinterpret_cast<char *>(&Courses[i].Name), sizeof(Courses[i].Name));
}
//end of saving
StudentRecordData *r;
r = new StudentRecordData(marks,Age,ID,CourseCount,FirstName,LastName, Courses);
node = new StudentRecordDataNode(r);
iList.AddNode(node);
} while (!is.eof());
//nd=iList.getFirstNode();
sortNodes(node);
for(nd=iList.getFirstNode();nd;nd=iList.getNextNode(nd))
nd->getValue()->display();
is.close();
cin.get();
return;
}
| |